mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-08 09:47:30 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e53dfe985 | ||
|
|
a435b7baa9 | ||
|
|
9d92bd6d8e | ||
|
|
29a1772e06 | ||
|
|
e02ef7fe8d | ||
|
|
93f485e7e2 | ||
|
|
49e515d9ba | ||
|
|
fb1b7c9060 | ||
|
|
f39b4a8582 | ||
|
|
06ceb7da90 | ||
|
|
934b4388cb | ||
|
|
055710e95a | ||
|
|
12e6c6d95f | ||
|
|
cd11446263 | ||
|
|
844c90a395 | ||
|
|
f9ee6d3d9e | ||
|
|
2d73699721 | ||
|
|
4caca1d6eb | ||
|
|
64595cc959 | ||
|
|
fb49473192 | ||
|
|
5c6ec3c7bf | ||
|
|
a86833cc06 | ||
|
|
dc1ff44e37 | ||
|
|
ed235cf8b7 | ||
|
|
adb0cb5c01 | ||
|
|
964d412062 | ||
|
|
3cb5d4790a | ||
|
|
a6faca14b7 | ||
|
|
4bbf5a04ed | ||
|
|
99a15a90c7 | ||
|
|
b7e1d6a196 | ||
|
|
7d884d8e7b | ||
|
|
106d6a77ce | ||
|
|
d10a337f00 | ||
|
|
43b21ea95f | ||
|
|
42bb3ed035 | ||
|
|
e88d05b9a5 | ||
|
|
5771743122 | ||
|
|
dbe6bdca91 | ||
|
|
ed101fb57d | ||
|
|
d689414621 | ||
|
|
05729165c3 | ||
|
|
192c93ce8e | ||
|
|
1fbcdd2102 | ||
|
|
474aa9fbdf | ||
|
|
37fb4ddb51 | ||
|
|
242cb5ca83 | ||
|
|
f9f1414172 | ||
|
|
4f005f63d5 | ||
|
|
53584a7dfd | ||
|
|
1784f408bc | ||
|
|
811b353f22 | ||
|
|
a94cc66d1c | ||
|
|
c5f264a8e0 | ||
|
|
e78a9cc5d7 | ||
|
|
eb9ce1f481 | ||
|
|
c0c2b6916e | ||
|
|
57edb51964 | ||
|
|
3d1401d458 | ||
|
|
bd7cb92852 | ||
|
|
18e00ac0a3 | ||
|
|
1bc1289953 | ||
|
|
6adaa2c394 | ||
|
|
ac1f6d72cd | ||
|
|
fe130827b6 | ||
|
|
c43d9ad351 | ||
|
|
568e301e46 | ||
|
|
a47cc80ad9 | ||
|
|
3f12d0f2e7 | ||
|
|
aa431db411 | ||
|
|
f36bc79e87 | ||
|
|
e763001682 | ||
|
|
53da694542 | ||
|
|
3af0eb20a0 | ||
|
|
5c46b61769 | ||
|
|
0752ba8bc9 | ||
|
|
c5790584df | ||
|
|
bc015f22c9 | ||
|
|
f02b9373c0 | ||
|
|
c2ed94ed04 | ||
|
|
86d9796c17 | ||
|
|
21c10baabc | ||
|
|
00f74e44b3 | ||
|
|
43ae28411d | ||
|
|
a69c752d39 | ||
|
|
72cee8e34f | ||
|
|
62a7f935b8 | ||
|
|
be955c576f | ||
|
|
691a5a5314 | ||
|
|
30291f81e3 | ||
|
|
72c4458108 | ||
|
|
71f5acedf9 | ||
|
|
86cb47ea9c | ||
|
|
544a3a93a9 | ||
|
|
d126bace5f | ||
|
|
f5e96952d8 | ||
|
|
eb1ef0b37b | ||
|
|
56b6d7b555 | ||
|
|
dd9ab596d2 | ||
|
|
83f57e0381 | ||
|
|
3fe419e7a2 | ||
|
|
f334499cec | ||
|
|
ed253b36ee | ||
|
|
bb41e69096 | ||
|
|
f193a2ca40 | ||
|
|
a67ba9a314 | ||
|
|
34b94f143e | ||
|
|
23390048f0 | ||
|
|
4d518b1a2e | ||
|
|
41806af161 | ||
|
|
b71a29c587 | ||
|
|
fb9c8f841f | ||
|
|
1d03836951 | ||
|
|
bec22b1ce4 | ||
|
|
dd1cedd5ca | ||
|
|
9c999b3d71 | ||
|
|
1bb515dc2c | ||
|
|
d89eed693b | ||
|
|
fa002563bc | ||
|
|
b605fd9ec6 | ||
|
|
3d77a3087c | ||
|
|
d7f9043378 | ||
|
|
e4c4689c3e | ||
|
|
783a4a7d74 | ||
|
|
2a6153f007 | ||
|
|
9f3f7701f8 | ||
|
|
e70afa0c54 | ||
|
|
c213d9392c | ||
|
|
5985d044b1 | ||
|
|
9905ed2b05 | ||
|
|
0b81ec337c | ||
|
|
e0fb69cfc4 | ||
|
|
58b07a4f2c | ||
|
|
0ed61df9d5 | ||
|
|
de9cf6516f | ||
|
|
24440f1df2 | ||
|
|
fd4fb6bddc | ||
|
|
3bfd4173a2 | ||
|
|
8dc6530c67 | ||
|
|
a032a7e82a | ||
|
|
f44cd6f30e | ||
|
|
3dcb8f933f | ||
|
|
5d2bb8b8d5 | ||
|
|
2721e6afa7 | ||
|
|
77b892c26e | ||
|
|
b89c43519a | ||
|
|
54175c5fe6 | ||
|
|
3df45d6dd8 | ||
|
|
453d7c8e4d | ||
|
|
c959af2365 | ||
|
|
827b7998f9 | ||
|
|
819a2fc1fd | ||
|
|
605682b3c8 | ||
|
|
44a43188a6 | ||
|
|
452e8a0660 | ||
|
|
b5e60437a0 | ||
|
|
be71676a11 | ||
|
|
2ea4681ff1 | ||
|
|
76cde0e16e | ||
|
|
8a06e8c6c7 | ||
|
|
09d7728c0a | ||
|
|
618fe005e6 | ||
|
|
205b621002 | ||
|
|
b866eac68f | ||
|
|
9c65107094 | ||
|
|
d3b47d4b2c | ||
|
|
f1d78e3ef5 | ||
|
|
b1cf064c35 | ||
|
|
590f13da18 | ||
|
|
a30a24dc0b | ||
|
|
d1ded86a63 | ||
|
|
205c2235fa | ||
|
|
0e1a181b47 | ||
|
|
5a673f727c | ||
|
|
32562cac4e | ||
|
|
79100113a7 | ||
|
|
1491b7a07d | ||
|
|
28b6e435bf | ||
|
|
3eec585f05 | ||
|
|
ea0d37a507 | ||
|
|
4f2d14d7da | ||
|
|
14a77654c1 | ||
|
|
254485dbea | ||
|
|
bd30c3c17c | ||
|
|
e4f620f894 | ||
|
|
f096c0ca6f | ||
|
|
fad7db9695 | ||
|
|
aa6046f941 | ||
|
|
401f3711f6 | ||
|
|
e672133aa8 | ||
|
|
c1a5d08fe1 | ||
|
|
20c3de56d5 | ||
|
|
f8113293d3 | ||
|
|
f4166f11e9 | ||
|
|
7f4ff662fe | ||
|
|
37461bd51f | ||
|
|
653273f34f | ||
|
|
361b97226e | ||
|
|
96a9a83f15 | ||
|
|
c622d74952 | ||
|
|
496133babd | ||
|
|
2c7866cf8b | ||
|
|
e00cf495f7 | ||
|
|
c10647f7f0 | ||
|
|
cac350dc27 | ||
|
|
83fa61ef7b | ||
|
|
8fbfb292d0 | ||
|
|
3e13ac26e9 | ||
|
|
8aa98687fa | ||
|
|
131f5cfce2 | ||
|
|
3f9001850e | ||
|
|
4462ee40ec | ||
|
|
eb13b12855 | ||
|
|
1206b0c1e7 | ||
|
|
9e14a25a81 | ||
|
|
ce1bd6d110 | ||
|
|
8c5a1a03db | ||
|
|
0d10b7dead | ||
|
|
231b8e147f | ||
|
|
000eaf4a5a | ||
|
|
20d1c8d5d0 | ||
|
|
ec92b77e22 | ||
|
|
408a8dfead | ||
|
|
9080907ed7 | ||
|
|
3757566d4f | ||
|
|
8b4e565285 | ||
|
|
6277583f69 | ||
|
|
beb3b6b44a | ||
|
|
8b416f0334 | ||
|
|
9d277028e5 | ||
|
|
2b411094db | ||
|
|
a618edb5dd | ||
|
|
5064f0781f | ||
|
|
7ed66b20e5 | ||
|
|
910cb1be81 | ||
|
|
9a78224278 | ||
|
|
718a1eb400 | ||
|
|
c325305a7c | ||
|
|
3c612c6432 | ||
|
|
abd6206fee | ||
|
|
016b308031 | ||
|
|
de30eedb5e | ||
|
|
fe8b66a4fe | ||
|
|
5819639209 | ||
|
|
5ba7dbb89f | ||
|
|
edd5bf9267 | ||
|
|
e3f5063ec2 | ||
|
|
3e348ed92f | ||
|
|
8a0805cd3a | ||
|
|
8a7354d1fd | ||
|
|
9d5d693cf6 | ||
|
|
c808eacefb | ||
|
|
454666e36c | ||
|
|
a0ab5d239e | ||
|
|
5b2f73c7ac | ||
|
|
324eb12388 | ||
|
|
ca6c23c5db | ||
|
|
e5876039bb | ||
|
|
d8a09a7c5b | ||
|
|
4edfec2b6c | ||
|
|
4756d3234b | ||
|
|
29b19d979f | ||
|
|
529a68d134 | ||
|
|
8251af93d9 | ||
|
|
730634bbb4 | ||
|
|
b8ef38a0e2 | ||
|
|
58c70caf41 | ||
|
|
85ca6a5fb7 | ||
|
|
f07d389ef2 | ||
|
|
c3a9018ac4 | ||
|
|
72ff5105ef | ||
|
|
1fd19dc38d | ||
|
|
911042faeb | ||
|
|
9ecbb3cfd1 | ||
|
|
fc7bb77cd5 | ||
|
|
5336747ece | ||
|
|
7662c57e57 | ||
|
|
474f6007e2 | ||
|
|
ea25cdd7b7 | ||
|
|
4d65bfe327 | ||
|
|
e2ecf549e1 | ||
|
|
8daa261b97 | ||
|
|
5065f8bcb8 | ||
|
|
6fa911f091 | ||
|
|
6ac350d1b8 | ||
|
|
c998e8137e | ||
|
|
c104474c3c | ||
|
|
0555ad1f5d | ||
|
|
2671926476 | ||
|
|
30d72b04b5 | ||
|
|
663b247700 | ||
|
|
f2135637e9 | ||
|
|
4f8ae68563 | ||
|
|
5933b60dc0 | ||
|
|
05e13601c9 | ||
|
|
af5e1c0364 | ||
|
|
0b1db2afae | ||
|
|
30c35d4330 | ||
|
|
61aa311e62 | ||
|
|
8a010b513e | ||
|
|
29b1a4e97d | ||
|
|
e57cb388e2 | ||
|
|
fa742989b5 | ||
|
|
72f7116854 | ||
|
|
8c5aad339d | ||
|
|
6cd5cc0fa0 | ||
|
|
33f08d0231 | ||
|
|
20120ecff3 | ||
|
|
53b34e0e34 | ||
|
|
4ac3fdc8d9 | ||
|
|
9363eaae3d | ||
|
|
1c1401787a | ||
|
|
902167c255 | ||
|
|
12cb33af5d | ||
|
|
a810e44570 | ||
|
|
8ec3b47402 | ||
|
|
f893cc65e1 | ||
|
|
98e8dede11 | ||
|
|
c87a849a3e | ||
|
|
3d343076ee | ||
|
|
86733d3b4f | ||
|
|
1b7d024e5c | ||
|
|
cfafb32049 | ||
|
|
c68550c45d | ||
|
|
74d82d0cb7 | ||
|
|
4e98e2d832 | ||
|
|
0d03789fb9 | ||
|
|
a8677aafbc | ||
|
|
4f9949dc2a | ||
|
|
05d1e6d88f | ||
|
|
5fcc8ca854 | ||
|
|
760add1c63 | ||
|
|
35d8b9408e | ||
|
|
e1e8ee1924 | ||
|
|
15c658f21f | ||
|
|
58269f1769 | ||
|
|
b736409e52 | ||
|
|
dd955a3b41 | ||
|
|
c5c68f4d36 |
No files matched your search
@@ -1,285 +0,0 @@
|
||||
define dump_bt
|
||||
set $t = $arg0
|
||||
while $t
|
||||
printf "[0x%08x] ", $t
|
||||
if $t->function_state.function->common.function_name
|
||||
printf "%s() ", $t->function_state.function->common.function_name
|
||||
else
|
||||
printf "??? "
|
||||
end
|
||||
if $t->op_array != 0
|
||||
printf "%s:%d ", $t->op_array->filename, $t->opline->lineno
|
||||
end
|
||||
set $t = $t->prev_execute_data
|
||||
printf "\n"
|
||||
end
|
||||
end
|
||||
|
||||
document dump_bt
|
||||
dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
|
||||
end
|
||||
|
||||
define printzv
|
||||
set $ind = 0
|
||||
____printzv $arg0 0
|
||||
end
|
||||
|
||||
document printzv
|
||||
prints content of zval
|
||||
end
|
||||
|
||||
define ____printzv
|
||||
set $zvalue = $arg0
|
||||
|
||||
if $zvalue->type == 0
|
||||
set $typename = "NULL"
|
||||
end
|
||||
if $zvalue->type == 1
|
||||
set $typename = "long"
|
||||
end
|
||||
if $zvalue->type == 2
|
||||
set $typename = "double"
|
||||
end
|
||||
if $zvalue->type == 3
|
||||
set $typename = "string"
|
||||
end
|
||||
if $zvalue->type == 4
|
||||
set $typename = "array"
|
||||
end
|
||||
if $zvalue->type == 5
|
||||
set $typename = "object"
|
||||
end
|
||||
if $zvalue->type == 6
|
||||
set $typename = "bool"
|
||||
end
|
||||
if $zvalue->type == 7
|
||||
set $typename = "resource"
|
||||
end
|
||||
if $zvalue->type == 8
|
||||
set $typename = "constant"
|
||||
end
|
||||
if $zvalue->type == 9
|
||||
set $typename = "const_array"
|
||||
end
|
||||
|
||||
printf "[0x%08x] ", $zvalue
|
||||
|
||||
if $zvalue == executor_globals.uninitialized_zval_ptr
|
||||
printf "*uninitialized* "
|
||||
end
|
||||
printf "(refcount=%d) %s: ", $zvalue->refcount, $typename
|
||||
if $zvalue->type == 1
|
||||
printf "%ld", $zvalue->value.lval
|
||||
end
|
||||
if $zvalue->type == 2
|
||||
printf "%lf", $zvalue->value.dval
|
||||
end
|
||||
if $zvalue->type == 3
|
||||
printf "\"%s\"(%d)", $zvalue->value.str.val, $zvalue->value.str.len
|
||||
end
|
||||
if $zvalue->type == 4
|
||||
if ! $arg1
|
||||
printf "{\n"
|
||||
set $ind = $ind + 1
|
||||
____print_ht $zvalue->value.ht
|
||||
set $ind = $ind - 1
|
||||
set $i = $ind
|
||||
while $i > 0
|
||||
printf " "
|
||||
set $i = $i - 1
|
||||
end
|
||||
printf "}"
|
||||
end
|
||||
end
|
||||
if $zvalue->type == 5
|
||||
if ! $arg1
|
||||
printf "(prop examination disabled due to a gdb bug)"
|
||||
# set $ht = $zvalue->value.obj.handlers->get_properties($zvalue)
|
||||
# printf "{\n"
|
||||
# set $ind = $ind + 1
|
||||
# ____print_ht $ht
|
||||
# set $ind = $ind - 1
|
||||
# set $i = $ind
|
||||
# while $i > 0
|
||||
# printf " "
|
||||
# set $i = $i - 1
|
||||
# end
|
||||
# printf "}"
|
||||
end
|
||||
end
|
||||
if $zvalue->type == 6
|
||||
if $zvalue->lval
|
||||
printf "true"
|
||||
else
|
||||
printf "false"
|
||||
end
|
||||
end
|
||||
if $zvalue->type == 7
|
||||
printf "#%d", $zvalue->value.lval
|
||||
end
|
||||
printf "\n"
|
||||
end
|
||||
|
||||
define ____print_ht
|
||||
set $ht = $arg0
|
||||
set $p = $ht->pListHead
|
||||
|
||||
while $p != 0
|
||||
set $zval = *(struct _zval_struct **)$p->pData
|
||||
|
||||
set $i = $ind
|
||||
while $i > 0
|
||||
printf " "
|
||||
set $i = $i - 1
|
||||
end
|
||||
|
||||
if $p->nKeyLength > 0
|
||||
printf "\"%s\" => ", $p->arKey
|
||||
else
|
||||
printf "%d => ", $p->h
|
||||
end
|
||||
|
||||
____printzv $zval 1
|
||||
set $p = $p->pListNext
|
||||
end
|
||||
end
|
||||
|
||||
define print_ht
|
||||
set $ind = 1
|
||||
printf "[0x%08x] {\n", $arg0
|
||||
____print_ht $arg0
|
||||
printf "}\n"
|
||||
end
|
||||
|
||||
document print_ht
|
||||
dumps elements of HashTable made of zval
|
||||
end
|
||||
|
||||
define printzn
|
||||
set $ind = 0
|
||||
set $znode = $arg0
|
||||
if $znode->op_type == 1
|
||||
set $optype = "IS_CONST"
|
||||
end
|
||||
if $znode->op_type == 2
|
||||
set $optype = "IS_TMP_VAR"
|
||||
end
|
||||
if $znode->op_type == 4
|
||||
set $optype = "IS_VAR"
|
||||
end
|
||||
if $znode->op_type == 8
|
||||
set $optype = "IS_UNUSED"
|
||||
end
|
||||
|
||||
printf "[0x%08x] %s", $znode, $optype
|
||||
|
||||
if $znode->op_type == 1
|
||||
printf ": "
|
||||
____printzv &$znode->u.constant
|
||||
end
|
||||
if $znode->op_type == 2
|
||||
printf ": "
|
||||
set $tvar = (union _temp_variable *)((char *)executor_globals.current_execute_data->Ts + $znode->u.var)
|
||||
____printzv ((union _temp_variable *)$tvar)->tmp_var
|
||||
end
|
||||
if $znode->op_type == 4
|
||||
printf ": "
|
||||
set $tvar = (union _temp_variable *)((char *)executor_globals.current_execute_data->Ts + $znode->u.var)
|
||||
____printzv *$tvar->var.ptr_ptr
|
||||
end
|
||||
if $znode->op_type == 8
|
||||
printf "\n"
|
||||
end
|
||||
end
|
||||
|
||||
document printzn
|
||||
print type and content of znode.
|
||||
usage: printzn &opline->op1
|
||||
end
|
||||
|
||||
define printzops
|
||||
printf "op1 => "
|
||||
printzn &execute_data->opline.op1
|
||||
printf "op2 => "
|
||||
printzn &execute_data->opline.op2
|
||||
printf "result => "
|
||||
printzn &execute_data->opline.result
|
||||
end
|
||||
|
||||
document printzops
|
||||
dump operands of the current opline
|
||||
end
|
||||
|
||||
define zmemcheck
|
||||
set $p = alloc_globals.head
|
||||
set $stat = "?"
|
||||
set $total_size = 0
|
||||
if $arg0 != 0
|
||||
set $not_found = 1
|
||||
else
|
||||
set $not_found = 0
|
||||
end
|
||||
printf " block size status file:line\n"
|
||||
printf "-------------------------------------------------------------------------------\n"
|
||||
while $p
|
||||
set $aptr = $p + sizeof(struct _zend_mem_header) + sizeof(align_test)
|
||||
if $arg0 == 0 || (void *)$aptr == (void *)$arg0
|
||||
if $p->magic == 0x7312f8dc
|
||||
set $stat = "OK"
|
||||
end
|
||||
if $p->magic == 0x99954317
|
||||
set $stat = "FREED"
|
||||
end
|
||||
if $p->magic == 0xfb8277dc
|
||||
set $stat = "CACHED"
|
||||
end
|
||||
set $filename = strrchr($p->filename, '/')
|
||||
if !$filename
|
||||
set $filename = $p->filename
|
||||
else
|
||||
set $filename = $filename + 1
|
||||
end
|
||||
printf " 0x%08x ", $aptr
|
||||
if $p->size == sizeof(struct _zval_struct) && ((struct _zval_struct *)$aptr)->type >= 0 && ((struct _zval_struct *)$aptr)->type < 10
|
||||
printf "ZVAL?(%-2d) ", $p->size
|
||||
else
|
||||
printf "%-9d ", $p->size
|
||||
end
|
||||
set $total_size = $total_size + $p->size
|
||||
printf "%-06s %s:%d", $stat, $filename, $p->lineno
|
||||
if $p->orig_filename
|
||||
set $orig_filename = strrchr($p->orig_filename, '/')
|
||||
if !$orig_filename
|
||||
set $orig_filename = $p->orig_filename
|
||||
else
|
||||
set $orig_filename = $orig_filename + 1
|
||||
end
|
||||
printf " <= %s:%d\n", $orig_filename, $p->orig_lineno
|
||||
else
|
||||
printf "\n"
|
||||
end
|
||||
if $arg0 != 0
|
||||
set $p = 0
|
||||
set $not_found = 0
|
||||
else
|
||||
set $p = $p->pNext
|
||||
end
|
||||
else
|
||||
set $p = $p->pNext
|
||||
end
|
||||
end
|
||||
if $not_found
|
||||
printf "no such block that begins at 0x%08x.\n", $aptr
|
||||
end
|
||||
if $arg0 == 0
|
||||
printf "-------------------------------------------------------------------------------\n"
|
||||
printf " total: %d bytes\n", $total_size
|
||||
end
|
||||
end
|
||||
|
||||
document zmemcheck
|
||||
show status of a memory block.
|
||||
usage: zmemcheck [ptr].
|
||||
if ptr is 0, all blocks will be listed.
|
||||
end
|
||||
|
||||
+17
-88
@@ -13,8 +13,6 @@ these rules.
|
||||
Code Implementation
|
||||
-------------------
|
||||
|
||||
[0] Document your code in source files and the manual. [tm]
|
||||
|
||||
[1] Functions that are given pointers to resources should not free them
|
||||
|
||||
For instance, function int mail(char *to, char *from) should NOT free
|
||||
@@ -48,92 +46,23 @@ Exceptions:
|
||||
doing so, should return that new length, so it doesn't have to be
|
||||
recalculated with strlen() (e.g. php_addslashes())
|
||||
|
||||
[5] Use php_error_docref() group of functions 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.
|
||||
|
||||
It has been silently agreed to prefix every php_error() message with the
|
||||
name of the current function if applicable:
|
||||
|
||||
php_error(E_WHATEVER, "%s(): Desc.", get_active_function_name(TSRMLS_C));
|
||||
|
||||
This can be done automatically using php_error_docref(). The first
|
||||
parameter, docref, is either NULL or the URL of a page describing the
|
||||
error in detail. In most cases you will pass NULL, to generate the URL
|
||||
from the name of the function being executed:
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WHATEVER, "Desc.");
|
||||
|
||||
If you pass a URL, it can either be a full URL beginning with "http://":
|
||||
|
||||
php_error_docref("http://externalsite.tld/page.ext#error"
|
||||
TSRMLS_CC, E_WHATEVER, "Desc.");
|
||||
|
||||
Or the name of a manual page without file extension, but with an optional
|
||||
target anchor. Or simply the anchor within the manual page of the current
|
||||
function. When using function names you must replace '_' by '-':
|
||||
|
||||
php_error_docref("function.ext-func#error" TSRMLS_CC, E_WHATEVER, "Desc.");
|
||||
|
||||
To display one or two important parameters after the function name, use
|
||||
php_error_docref1() or php_error_docref2(). For example, file functions
|
||||
should display the name of the file opened:
|
||||
|
||||
php_error_docref1("function.fopen" TSRMLS_CC, filename,
|
||||
E_WHATEVER, "Desc.");
|
||||
|
||||
php_error_docref2("function.fopen" TSRMLS_CC, filename, openmode,
|
||||
E_WHATEVER, "Desc.");
|
||||
|
||||
Fixing ("unifying") existing php_error() message is a good thing [tm].
|
||||
[5] Use php_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.
|
||||
|
||||
[7] Use PHP_* macros in the PHP source, and ZEND_* macros in the Zend
|
||||
part of the source. Although the PHP_* macro's are mostly aliased to the
|
||||
ZEND_* macros it gives a better understanding on what kind of macro you're
|
||||
calling.
|
||||
|
||||
[8] Use assert(). assert.h is included in php.h if it is available. Not only
|
||||
does good assertion catch bugs, but it also helps with code readability.
|
||||
- Do not use assert for error handling. Use assert only for the
|
||||
condition that must be always true.
|
||||
- Do not use assignments in assert conditions. If you assign inside an
|
||||
assert condition, you risk an elusive bug that would be very difficult
|
||||
to spot in a debug build, due to the side effect of the assignment.
|
||||
Function calls in assert conditions may also cause this problem, if
|
||||
they modify one of their arguments or global variables.
|
||||
|
||||
[9] When commenting out code using a #if statement, do NOT use 0 only. Instead
|
||||
use "<cvs username here>_0". For example, #if FOO_0, where FOO is your
|
||||
cvs user foo. This allows easier tracking of why code was commented out,
|
||||
especially in bundled libraries.
|
||||
|
||||
[10] Do not define functions that are not available. For instance, if a
|
||||
library is missing a function, do not define the PHP version of the
|
||||
function, and do not raise a run-time error about the function not
|
||||
existing. End users should use function_exists() to test for the
|
||||
existence of a function
|
||||
|
||||
[11] Prefer emalloc(), efree(), estrdup(), etc. to their standard C library
|
||||
counterparts. These functions implement an internal "safety-net"
|
||||
mechanism that ensures the deallocation of any unfreed memory at the
|
||||
end of a request. They also provide useful allocation and overflow
|
||||
information while running in debug mode.
|
||||
|
||||
In almost all cases, memory returned to the engine must be allocated
|
||||
using emalloc().
|
||||
|
||||
The use of malloc() should be limited to cases where a third-party
|
||||
library may need to control or free the memory, or when the memory in
|
||||
question needs to survive between multiple requests.
|
||||
[7] Use ZEND_* macro instead of PHP_* macro. Use of PHP_* macros are
|
||||
not recommended. Since most of PHP_* macros are ZEND_* macro alias, use of
|
||||
PHP_* macro makes browsing source with tag search harder.
|
||||
|
||||
Naming Conventions
|
||||
------------------
|
||||
@@ -213,13 +142,13 @@ Syntax and indentation
|
||||
|
||||
[3] Be generous with whitespace and braces. Always prefer:
|
||||
|
||||
if (foo) {
|
||||
bar;
|
||||
}
|
||||
if (foo) {
|
||||
bar;
|
||||
}
|
||||
|
||||
to:
|
||||
to:
|
||||
|
||||
if(foo)bar;
|
||||
if(foo)bar;
|
||||
|
||||
Keep one empty line between the variable declaration section and
|
||||
the statements in a block, as well as between logical statement
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
For the list of people who've put work into PHP, please see
|
||||
For the list of people who've put work into PHP 4.0, please see
|
||||
http://www.php.net/credits.php
|
||||
+18
-62
@@ -31,29 +31,15 @@ EXTENSION: aolserver
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: activescript
|
||||
PRIMARY MAINTAINER: Wez Furlong <wez@php.net>
|
||||
MAINTENANCE: Odd Fixes
|
||||
STATUS: Experimental
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: apache
|
||||
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: apache2
|
||||
PRIMARY MAINTAINER: Aaron Bannert <aaron@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Experimental
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: cgi
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: cli
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: fhttpd
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
@@ -63,9 +49,8 @@ MAINTENANCE: Unknown
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: nsapi
|
||||
PRIMARY MAINTAINER: Uwe Schindler <thetaphi@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: phttpd
|
||||
MAINTENANCE: Unknown
|
||||
@@ -99,7 +84,7 @@ STATUS: Experimental
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: dba
|
||||
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>
|
||||
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -136,7 +121,7 @@ STATUS: Experimental
|
||||
SINCE: 4.0.2
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: interbase
|
||||
PRIMARY MAINTAINER: Jouni Ahto <jouni.ahto@exdec.fi>, Ard Biesheuvel <ard@ard.nu>
|
||||
PRIMARY MAINTAINER: Jouni Ahto <jouni.ahto@exdec.fi>
|
||||
MAINTENANCE: Odd Fixes
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -157,8 +142,7 @@ STATUS: Working
|
||||
COMMENT: Tested on phpts and isapi versions
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: mysql
|
||||
PRIMARY MAINTAINER: Zak Greant <zak@mysql.com>, Georg Richter <georg@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: pgsql
|
||||
@@ -184,7 +168,7 @@ EXTENSION: odbc
|
||||
PRIMARY MAINTAINER: Daniel R. Kalowsky <kalowsky@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
COMMENT: Working
|
||||
COMMENT: Working except for persistent connections
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: oracle
|
||||
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
|
||||
@@ -207,23 +191,11 @@ MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: bz2
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
SINCE: 4.0.3
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: dio
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Orphaned
|
||||
STATUS: Working
|
||||
SINCE: 4.0.6
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: cyrus
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Orphaned
|
||||
STATUS: Working
|
||||
SINCE: 4.0.6
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: calendar
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
@@ -244,11 +216,6 @@ MAINTENANCE: Unknown
|
||||
STATUS: Experimental
|
||||
SINCE: 4.0.5
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: ctype
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: curl
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
@@ -281,15 +248,9 @@ PRIMARY MAINTAINER: Uwe Steinmann <steinm@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: fribidi
|
||||
PRIMARY MAINTAINER: Tal Peer <tal@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: ftp
|
||||
PRIMARY MAINTAINER: Stefan Esser (sesser@php.net)
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Unknown
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: gd
|
||||
PRIMARY MAINTAINER: Rasmus Lerdorf <rasmus@php.net>
|
||||
@@ -309,11 +270,6 @@ EXTENSION: icap
|
||||
MAINTENANCE: Unknown
|
||||
STATUS: Obsolete
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: iconv
|
||||
PRIMARY MAINTAINER: Moriyoshi Koizumi <moriyoshi@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: imap
|
||||
PRIMARY MAINTAINER: Chuck Hagenbuch <chuck@horde.org>
|
||||
MAINTENANCE: Odd Fixes
|
||||
@@ -451,8 +407,8 @@ SINCE: 4.0.2
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: swf
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Orphaned
|
||||
STATUS: Deprecated (Use the ming swf extension instead)
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Depreciated (Use the ming swf extension instead)
|
||||
COMMENT: Only for Unix (won't change)
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: sysvsem
|
||||
@@ -479,9 +435,9 @@ MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: xslt
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
STATUS: Working (mostly)
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANC: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: yaz
|
||||
PRIMARY MAINTAINER: Adam Dickmeiss <adam@indexdata.dk>
|
||||
@@ -499,9 +455,9 @@ MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: zziplib
|
||||
PRIMARY MAINTAINER: Hartmut Holzgraefe <hartmut@six.de>
|
||||
MAINTENANCE: Odd Fixes
|
||||
STATUS: Working
|
||||
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Experimental
|
||||
SINCE: 4.0.5
|
||||
-------------------------------------------------------------------------------
|
||||
# iptc?
|
||||
@@ -1,5 +1,5 @@
|
||||
Installation Instructions for PHP 4
|
||||
-----------------------------------
|
||||
Installation Instructions for PHP 4.1
|
||||
-------------------------------------
|
||||
|
||||
STOP!
|
||||
|
||||
@@ -8,11 +8,6 @@ up to date instructions in the online manual, located here:
|
||||
|
||||
http://www.php.net/manual/en/install.apache.php
|
||||
|
||||
For Apache 2, instructions and up-to-date information regarding it's
|
||||
support status, is available here:
|
||||
|
||||
http://www.php.net/manual/en/install.apache2.php
|
||||
|
||||
It is strongly recommended that you read the manual page before going
|
||||
further. However, 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
|
||||
@@ -67,8 +62,8 @@ Compiled-in modules:
|
||||
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.x.y.tar.gz | tar xf -
|
||||
$ cd php-4.x.y
|
||||
$ gunzip -c php-4.1.x.tar.gz | tar xf -
|
||||
$ cd php-4.1.x
|
||||
$ ./configure --with-mysql --with-apxs
|
||||
$ make
|
||||
$ make install
|
||||
@@ -77,9 +72,6 @@ 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
|
||||
|
||||
Make sure you specify the version of apxs that is actually installed on
|
||||
your system and NOT the one that is in the apache source tarball.
|
||||
|
||||
Next you must copy php.ini-dist to the appropriate place (normally
|
||||
/usr/local/lib/php.ini) and edit it as necessary to set PHP options.
|
||||
|
||||
@@ -101,8 +93,8 @@ $ cd apache_1.3.x
|
||||
$ ./configure
|
||||
$ cd ..
|
||||
|
||||
$ gunzip -c php-4.x.y.tar.gz | tar xf -
|
||||
$ cd php-4.x.y
|
||||
$ gunzip -c php-4.1.x.tar.gz | tar xf -
|
||||
$ cd php-4.1.x
|
||||
$ ./configure --with-mysql --with-apache=../apache_1.3.x
|
||||
$ make
|
||||
$ make install
|
||||
@@ -114,7 +106,7 @@ $ ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a
|
||||
$ make
|
||||
(you should now have an httpd binary which you can copy to your Apache bin dir if
|
||||
is is your first install then you need to "make install" as well)
|
||||
$ cd ../php-4.x.y
|
||||
$ cd ../php-4.1.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:
|
||||
@@ -133,12 +125,12 @@ 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.x.y.tar.gz.
|
||||
Unzip this file with a command like: gunzip php-4.x.y.tar.gz
|
||||
You will have downloaded a file named something like php-4.1.x.tar.gz.
|
||||
Unzip this file with a command like: gunzip php-4.1.x.tar.gz
|
||||
|
||||
Next you have to untar it with: tar -xvf php-4.x.y.tar
|
||||
Next you have to untar it with: tar -xvf php-4.1.x.tar
|
||||
|
||||
This will create a php-4.x.y directory. cd into this new directory.
|
||||
This will create a php-4.1.x directory. cd into this new directory.
|
||||
|
||||
2a. Configure PHP (Dynamic Module) - Skip to 2b if you wish to build
|
||||
a static module
|
||||
@@ -168,9 +160,6 @@ Installing PHP can be done in four simple steps:
|
||||
look for it on your system and if you find it, provide the full path to it
|
||||
as: --with-apxs=/path/to/apxs
|
||||
|
||||
Make sure you specify the version of apxs that is actually installed on
|
||||
your system and NOT the one that is in the apache source tarball.
|
||||
|
||||
You might also want other flags on this configure line. --with-mysql
|
||||
is just an example.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--------------------------------------------------------------------
|
||||
The PHP License, version 3.0
|
||||
The PHP License, version 2.02
|
||||
Copyright (c) 1999 - 2002 The PHP Group. All rights reserved.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
@@ -8,38 +8,48 @@ 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.
|
||||
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.
|
||||
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 written permission. For
|
||||
written permission, please contact group@php.net.
|
||||
|
||||
4. Products derived from this software may not be called "PHP", nor
|
||||
may "PHP" appear in their name, without prior written permission
|
||||
from group@php.net. You may indicate that your software works in
|
||||
conjunction with PHP by saying "Foo for PHP" instead of calling
|
||||
it "PHP Foo" or "phpfoo"
|
||||
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.
|
||||
|
||||
5. The PHP Group may publish revised and/or new versions of the
|
||||
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
|
||||
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.
|
||||
|
||||
6. Redistributions of any form whatsoever must retain the following
|
||||
5. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes PHP, freely available from
|
||||
<http://www.php.net/>".
|
||||
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,
|
||||
@@ -63,6 +73,3 @@ 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>.
|
||||
|
||||
This product includes the Zend Engine, freely available at
|
||||
<http://www.zend.com>.
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
#
|
||||
# Zend
|
||||
#
|
||||
|
||||
$(builddir)/zend_language_scanner.lo: $(builddir)/zend_language_parser.h
|
||||
$(builddir)/zend_ini_scanner.lo: $(builddir)/zend_ini_parser.h
|
||||
|
||||
$(builddir)/zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
|
||||
$(LEX) -Pzend -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_language_scanner.l
|
||||
|
||||
$(builddir)/zend_language_parser.h: $(builddir)/zend_language_parser.c
|
||||
$(builddir)/zend_language_parser.c: $(srcdir)/zend_language_parser.y
|
||||
$(YACC) -p zend -v -d $(srcdir)/zend_language_parser.y -o $@
|
||||
|
||||
$(builddir)/zend_ini_parser.h: $(builddir)/zend_ini_parser.c
|
||||
$(builddir)/zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
|
||||
$(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o $@
|
||||
|
||||
$(builddir)/zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
|
||||
$(LEX) -Pini_ -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_ini_scanner.l
|
||||
|
||||
$(builddir)/zend_indent.lo $(builddir)/zend_highlight.lo $(builddir)/zend_compile.lo: $(builddir)/zend_language_parser.h
|
||||
@@ -1,78 +0,0 @@
|
||||
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
|
||||
INSTALL = $(top_srcdir)/build/shtool install -c
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
|
||||
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
|
||||
|
||||
|
||||
all: $(all_targets)
|
||||
@echo
|
||||
@echo "Build complete."
|
||||
@echo "(It is safe to ignore warnings about tempnam and tmpnam)."
|
||||
@echo
|
||||
|
||||
build-modules: $(PHP_MODULES)
|
||||
|
||||
libphp4.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
|
||||
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
|
||||
-@$(LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1
|
||||
|
||||
libs/libphp4.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
|
||||
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp4.so
|
||||
|
||||
install: $(all_targets) $(install_targets)
|
||||
|
||||
install-sapi: $(OVERALL_TARGET)
|
||||
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
|
||||
-@$(mkinstalldirs) $(INSTALL_ROOT)$(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: build-modules
|
||||
@test -d modules && \
|
||||
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) && \
|
||||
echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" && \
|
||||
rm -f modules/*.la && \
|
||||
$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true
|
||||
|
||||
install-tester:
|
||||
@echo "Installing regression tester: $(INSTALL_ROOT)$(PEAR_INSTALLDIR)/"
|
||||
@$(mkinstalldirs) $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
|
||||
@$(INSTALL) -m 755 $(top_srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
|
||||
|
||||
install-su: install-pear install-tester
|
||||
|
||||
test:
|
||||
-@if test -x $(SAPI_CLI_PATH) && test ! -z $(SAPI_CLI_PATH); then \
|
||||
TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \
|
||||
TEST_PHP_SRCDIR=$(top_srcdir) \
|
||||
CC="$(CC)" \
|
||||
$(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' $(top_srcdir)/run-tests.php $(TESTS); \
|
||||
else \
|
||||
echo "ERROR: Cannot run tests without CLI sapi."; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
find . -name \*.lo | xargs rm -f
|
||||
find . -name \*.o | xargs rm -f
|
||||
find . -name \*.la | xargs rm -f
|
||||
find . -name \*.a | xargs rm -f
|
||||
find . -name \*.so | xargs rm -f
|
||||
find . -name .libs -a -type d|xargs rm -rf
|
||||
rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/*
|
||||
|
||||
distclean: clean
|
||||
rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp
|
||||
egrep define'.*include/php' configure|sed 's/.*>//'|xargs rm -f
|
||||
find . -name Makefile | xargs rm -f
|
||||
|
||||
.PHONY: all clean install distclean test
|
||||
.NOEXPORT:
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
|
||||
ZEND_DIR = $(srcdir)/Zend
|
||||
SUBDIRS = Zend main ext sapi $(TSRM_DIR) $(REGEX_DIR) $(CLI_DIR) . $(PEAR_DIR)
|
||||
|
||||
LTLIBRARY_NAME = libphp4.la
|
||||
LTLIBRARY_SOURCES = stub.c
|
||||
|
||||
LTLIBRARY_DEPENDENCIES = \
|
||||
Zend/libZend.la \
|
||||
sapi/$(PHP_SAPI)/libsapi.la \
|
||||
main/libmain.la \
|
||||
$(REGEX_LIB) \
|
||||
$(EXT_LTLIBS) \
|
||||
$(TSRM_LIB)
|
||||
|
||||
LTLIBRARY_LDFLAGS = -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS)
|
||||
LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS)
|
||||
|
||||
PROGRAM_NAME = php
|
||||
PROGRAM_SOURCES = stub.c
|
||||
PROGRAM_LDADD = libphp4.la $(EXT_PROGRAM_LDADD)
|
||||
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) $(INSTALL_ROOT)$(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) $(INSTALL_ROOT)$(moduledir) && \
|
||||
echo "installing shared modules into $(moduledir)" && \
|
||||
rm -f modules/*.la && \
|
||||
cp modules/* $(INSTALL_ROOT)$(moduledir) >/dev/null 2>&1 || true
|
||||
|
||||
install-tester:
|
||||
@echo "Installing regression tester"
|
||||
@$(mkinstalldirs) $(PEAR_INSTALLDIR)
|
||||
@$(INSTALL) -m 755 $(srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
|
||||
|
||||
install-pear: install-modules
|
||||
(cd pear && $(MAKE) install)
|
||||
|
||||
install-su: install-pear install-tester
|
||||
|
||||
clean-modules:
|
||||
rm -f modules/*
|
||||
|
||||
.NOEXPORT:
|
||||
@@ -1,942 +1,10 @@
|
||||
PHP 4 NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
25 Aug 2003, Version 4.3.3
|
||||
- Upgraded the bundled Expat library to version 1.95.6. (Jani)
|
||||
- Upgraded the bundled PCRE library to version 4.3. (Andrei)
|
||||
- Upgraded the bundled GD library to version GD 2.0.15. (Ilia)
|
||||
- Improved the engine to use POSIX/socket IO where feasible. (Sascha)
|
||||
- Improved the IMAP extension (Ilia)
|
||||
. Added imap_timeout() function. (bug #24161)
|
||||
. Added optional 'charset' parameter to imap_search() and imap_sort().
|
||||
(bug #22505)
|
||||
- Improved the InterBase extension (Daniela)
|
||||
. Added transaction constants: IBASE_REC_VERSION, IBASE_REC_NO_VERSION,
|
||||
IBASE_WRITE, IBASE_WAIT and IBASE_CONCURRENCY. (bugs #8797, #23887)
|
||||
. Made numeric/decimal datatype handling work on any platform.
|
||||
- Improved the NSAPI SAPI module (Uwe Schindler)
|
||||
. Added possibility to use PHP to generate HTTP error pages (404 Not Found..)
|
||||
. Added possibility to use PHP to generate directory listings for directories
|
||||
without index.html
|
||||
. php4_init (magnus.conf): new parameter to set alternate path to php.ini.
|
||||
(php_ini="/path/to/php.ini")
|
||||
. php4_execute (obj.conf): support for additional php.ini values.
|
||||
Allows different settings per virtual server.
|
||||
(See sapi/nsapi/nsapi-readme.txt for more information)
|
||||
. Added support for virtual().
|
||||
. Added nsapi_request_headers() and nsapi_response_headers() with aliases
|
||||
for apache compatibility.
|
||||
. Added "nsapi.read_timeout" php.ini option.
|
||||
. Synced $_SERVER variables to be similar to Apache variables.
|
||||
- Added DBA handler 'inifile' to support ini files. (Marcus)
|
||||
- Added a "DEBUG" note to 'php -v' output when --enable-debug is used. (Derick)
|
||||
- Added long options into CLI & CGI (e.g. --version). (Marcus)
|
||||
- Added a new parameter to preg_match*() that can be used to specify
|
||||
the starting offset in the subject string to match from. (Andrei)
|
||||
- Fixed possible integer overflows in:
|
||||
. base64_encode(). (Moriyoshi)
|
||||
. bundled GD library. (Ilia)
|
||||
- Fixed "mysql.connect_timeout" php.ini option to be settable with ini_set().
|
||||
(Rasmus)
|
||||
- Fixed FastCGI IIS document root problem. (Shane)
|
||||
- Fixed corruption of multibyte character including 0x5c as second
|
||||
byte in multipart/form-data. (Rui)
|
||||
- Fixed possible crash in imagerotate() when an invalid color index
|
||||
is used for background color. (Pierre-Alain Joye)
|
||||
- Fixed a bug that under certain circumstances could invalidate safe_mode.
|
||||
(Ilia)
|
||||
- Fixed certificate version and allowed setting of the serial number in
|
||||
openssl_csr_sign(). (Stefan Roehrich)
|
||||
- Fixed each() to be binary safe for keys. (Zeev)
|
||||
- Fixed ext/yaz to not log if "yaz.log_file" php.ini option is not set. (Adam)
|
||||
- Fixed a bug in bundled libmysql (mysql bug #564). (Georg)
|
||||
- Fixed ext/exif to honor "magic_quotes_runtime" php.ini option. (Marcus)
|
||||
- Fixed bug #25093 (ext/pgsql: Various leaks due to non-freed queries). (Ilia)
|
||||
- Fixed bug #25084 (ext/session: Fixed session.referer_check to be independent
|
||||
on register_globals). (Ilia)
|
||||
- Fixed bug #25081 (odbc_fetch_array() may mangle numeric fields). (Ilia)
|
||||
- Fixed bug #25044 (header("Location:") changing HTTP status). (Marcus)
|
||||
- Fixed bug #25037 (win32 mail(): Possible infinite loop inside SendText()).
|
||||
(Ilia)
|
||||
- Fixed bug #25007 (rand() & mt_rand() seed RNG every call). (Jani)
|
||||
- Fixed bug #24989 (external libexpat conflicts with bundled libexpat). (Jani)
|
||||
- Fixed bug #24980 (array_reduce() uses first element as default running
|
||||
total). (Ilia)
|
||||
- Fixed bug #24977 (Reverted mysql_select_db() optimization). (Ilia)
|
||||
- Fixed bug #24958 (Apache2 SAPIs: Incorrect handling of 404s). (Ilia, Justin)
|
||||
- Fixed bug #24951 (ob_flush() needlessly destroys output handler). (Ilia)
|
||||
- Fixed bug #24936 (ext/fdf not linked properly as shared extension). (Jani)
|
||||
- Fixed bug #24909 (Bad random numbers with ZTS builds on Solaris). (Ilia)
|
||||
- Fixed bug #24897 (inconsistent behavior of shuffle() & array_multisort()).
|
||||
(Ilia, Jani)
|
||||
- Fixed bug #24883 ("variables_order" and "gpc_order" being ignored). (Ilia)
|
||||
- Fixed bug #24873 (incorrect handling of / inside open_basedir). (Ilia)
|
||||
- Fixed bug #24871 (aggregate(): methods misidentified as constructors). (Ilia)
|
||||
- Fixed bug #24827 (ob_gzhandler overrides Vary header). (Ilia)
|
||||
- Fixed bug #24792 (--enable-zend-multibyte causes random segfaults with ZTS).
|
||||
(Fujimoto)
|
||||
- Fixed bug #24783 (foreach($ar as $key => $val), $key not binary safe). (Zeev)
|
||||
- Fixed bug #24760 (non-default SNMP port number not working). (Jani)
|
||||
- Fixed bug #24752 (Unhandled "uniqueidentifier" field type).
|
||||
(Ilia, s.sonnenberg[at]coolspot.de)
|
||||
- Fixed bug #24710 (Crash when $obj->{0} is used). (Zeev)
|
||||
- Fixed bug #24663 (\n. sequences were not being escaped). (Ilia)
|
||||
- Fixed bug #24640 (var_export() and var_dump() can not output large floats).
|
||||
(Marcus)
|
||||
- Fixed bug #24629 (FreeBSD select() does not like large microseconds values).
|
||||
(Mirco Bauer).
|
||||
- Fixed bug #24609 (ext/domxml: segfault when using replace node across
|
||||
different docs). (Rob Richards)
|
||||
- Fixed bug #24594 (Rewrite of the imagefill() function). (Pierre-Alain Joye)
|
||||
- Fixed bug #24592 (NULL related crash in session extension). (Sascha)
|
||||
- Fixed bug #24573 (debug_backtrace() crashes if $this set to null). (Jani)
|
||||
- Fixed bug #24560 (parse_url() incorrectly handling certain file:// based
|
||||
schemas). (Ilia)
|
||||
- Fixed bug #24557 (make fclose() respect refcount on the resource).
|
||||
(Wez, Ilia)
|
||||
- Fixed bug #24537 (apache2 compile misses some include directories). (Jani)
|
||||
- Fixed bug #24535 (ext/mysql: crash when retrieving data from unbuffered
|
||||
result after the original connection has been changed). (Ilia)
|
||||
- Fixed bug #24519 (aggregate_methods_by_list() does not increment refcount).
|
||||
- Fixed bug #24313 (file_exists() warning on non-existent files when
|
||||
open_basedir is used). (Ilia)
|
||||
- Fixed bug #24312 (base64_decode() does not skip 0xF0-0xFF characters).
|
||||
(gereon.steffens[at]onvista.de, Ilia)
|
||||
- Fixed bug #24284 (Fixed memory leak inside pg_ping()). (Ilia)
|
||||
- Fixed bug #24249 (fdf_add_doc_javascript() not available on Windows). (Edin)
|
||||
- Fixed bug #24224 (ibase_blob_get() overflow). (Ard)
|
||||
- Fixed bug #24223 (missing variable initialization in bundled gd). (Ilia)
|
||||
- Fixed bug #24220 (range() didn't handle numeric strings correctly). (Ilia)
|
||||
- Fixed bug #24210 (not detecting assume_default_colors - typo). (Sara)
|
||||
- Fixed bug #24198 (Invalid recursion detection in array_merge_recurcive()).
|
||||
(Ilia)
|
||||
- Fixed bug #24177 (Apache2 SAPIs: status set incorrectly after flush()).
|
||||
(Ilia)
|
||||
- Fixed bug #24155 (gdImageRotate270 incorrectly use x parameter for y axis).
|
||||
(tom@gksystems.com, Ilia)
|
||||
- Fixed bug #24150 (crash in imap_fetch_overview() &
|
||||
imap_rfc822_write_address()). (Ilia)
|
||||
- Fixed bug #24142 (workaround for a gcc bug affecting round()). (Marcus, Ilia)
|
||||
- Fixed bug #24063 (serialize() missing 0 after the . on scientific notation).
|
||||
(Marcus, Ilia)
|
||||
- Fixed bug #24063 (scientific notation broken in *printf()). (Ilia)
|
||||
- Fixed bug #24060 (ncurses_del_panel() causes segfault). (Georg)
|
||||
- Fixed bug #24054 (Integer overflow failure with GCC/x86 for *=). (Sascha)
|
||||
- Fixed bug #24028 (Reading raw post message by php://input failed). (Jani)
|
||||
- Fixed bug #24009 (FastCGI handling of file not found). (Shane)
|
||||
- Fixed bug #24007 (Problem with register_globals & arrays). (Ilia)
|
||||
- Fixed bug #23951 (constants in static initializers clobbered by inheritance).
|
||||
(Wez, Zend Engine)
|
||||
- Fixed bug #23936 (ext/interbase: fail to select and fetch). (Ard)
|
||||
- Fixed bug #23913 (make rename() work across partitions on *nix). (Ilia)
|
||||
- Fixed bug #23912 (Invalid CSS in phpinfo() output). (Ilia)
|
||||
- Fixed bug #23902 (NULL in CGI header output). (Shane)
|
||||
- Fixed bug #23898 (Proper handling of NULLs in odbc_result, odbc_fetch_into
|
||||
and odbc_result_all). (Ilia)
|
||||
- Fixed bug #23897 (Fixed a check for mbfilter_ru.h). (aleks@m2media.ru, Ilia)
|
||||
- Fixed bug #23894 (sprintf() decimal specifiers problem). (Moriyoshi)
|
||||
- Fixed bug #23888 (Missing input validation for flags parameter). (Ilia)
|
||||
- Fixed bug #23808 (broken imagecopymerge()). (Pierre-Alain Joye)
|
||||
- Fixed bug #23798 (Spaces were not being stripped from Bcc header). (Ilia)
|
||||
- Fixed bug #23792 (imagerotate() problems with limited platte, the function
|
||||
will always return true color image from now on). (Pierre-Alain Joye)
|
||||
- Fixed bug #23779 (mysql_connect(): disable local infile option if php.ini
|
||||
option "open_basedir" is set). (Georg)
|
||||
- Fixed bug #23769 (In FreeBSD glob() gives wrong result when pattern not
|
||||
found). (Hartmut)
|
||||
- Fixed bug #23733 (Coredump on startup with Oracle 9+). (Edin)
|
||||
- Fixed bug #23685 (fake values returned when OID value is an empty string).
|
||||
(Jani)
|
||||
- Fixed bug #23664 (FastCGI socket listenting). (Shane)
|
||||
- Fixed bug #23509 (exit code lost when exit() called from
|
||||
register_shutdown_function()). (Ilia)
|
||||
- Fixed bug #23463 (ext/dbase: added Dbase2 version check). (Vlad Krupin)
|
||||
- Fixed bug #23285 (Potential Stack overflow in zendlex). (Wez)
|
||||
- Fixed bug #23104 (hash position of static arrays not being reset). (Ilia)
|
||||
- Fixed bug #23038, #23574 (aggregate() related leaks and crashes). (Andrei)
|
||||
- Fixed bug #22947 (Ack() inside win32/sendmail.c may stall in certain
|
||||
situations). (Ilia)
|
||||
- Fixed bug #22690 (ob_start() did not work with create_function() callbacks).
|
||||
(Marcus)
|
||||
- Fixed bug #22592 (Cascading assignments to strings with curly braces broken).
|
||||
(Stas)
|
||||
- Fixed bug #22245 (References inside $_SESSION not being handled). (Ilia)
|
||||
- Fixed bug #22154 (Possible crash when memory_limit is reached and output
|
||||
buffering in addition to session.use_trans_sid is used). (Ilia)
|
||||
- Fixed bug #22072 (Apache2 sapis do not detect aborted connections). (Ilia)
|
||||
- Fixed bug #21958 (workaround for unusual realpath() on AIX & Tru64). (Ilia)
|
||||
- Fixed bug #21957 (serialize() mangles objects with __sleep). (Ilia)
|
||||
- Fixed bug #21918 (strange behaviour of mixed type in array-keys). (Marcus)
|
||||
- Fixed bug #21855 (Threading issue on HP-UX). (Roshan Naik, Andi, Moriyoshi)
|
||||
- Fixed bug #21611 (version_compare() does not support "p" as suffix).
|
||||
(Stefan Walk)
|
||||
- Fixed bug #21074 (Apache2: "ErrorDocument xxx /error.php" broken). (Jani)
|
||||
- Fixed bug #20896 (-s -w modes with php-cli cause php to hang). (Ilia)
|
||||
- Fixed bug #19613 (putenv("VAR=") does not empty VAR on win32). (Zeev)
|
||||
- Fixed bug #18744 (ibase_blob_add() has max limit of 64k). (Ard)
|
||||
- Fixed bug #18291 (escapeshellcmd() can now handle quoted arguments). (Ilia)
|
||||
- Fixed bug #17414 (pthreads bug workaround). (timo.teras[at]iki.fi)
|
||||
- Fixed bug #13142 (strtotime not handling "M d H:i:s Y" format). (Ilia)
|
||||
- Fixed bug #11924 (ibase_query(), ibase_execute() mangled passed parameters).
|
||||
(Jani)
|
||||
- Fixed bug #7014 (crash in _php_ibase_error() after request shutdown). (Ard)
|
||||
|
||||
29 May 2003, Version 4.3.2
|
||||
- Syncronized bundled GD library with GD 2.0.12. (Ilia)
|
||||
- Removed support for GDLIB version 1.x.x (php_gd.dll) on Windows. (Edin)
|
||||
- Enabled read-only GIF support in the bundled GDLIB (php_gd2.dll) on Windows.
|
||||
(Sebastian, Edin)
|
||||
- Improved dba extension (Marcus)
|
||||
. Added support for internal error handling of Berkeley db libraries.
|
||||
. Disallowed Berkeley db versions 4.1.0 to 4.1.24 due to locking problems.
|
||||
. Disallowed linkage of Berkeley db submodules against libraries with
|
||||
different major versions.
|
||||
. Disallowed configuring of more than one Berkeley db handler.
|
||||
. Reenabled dba_popen() with new persistent STDIO streams.
|
||||
- Added a new Apache 2.0 SAPI module (sapi/apache2handler) based on the old
|
||||
version (sapi/apache2filter). (Ian Holsman, Justin Erenkrantz)
|
||||
- Added "disable_classes" php.ini option to allow administrators to disable
|
||||
certain classes for security reasons. (Harald)
|
||||
- Added man page for CLI version of PHP. (Marcus)
|
||||
- Added --clean option into phpize. (Jani)
|
||||
- Added --ldflags option into php-config. (Jani)
|
||||
- Added imagesavealpha() and imageistruecolor() functions. (Pierre)
|
||||
- Added XBM support for bundled GD library. (Marcus)
|
||||
- Added session_regenerate_id() function. (Sascha)
|
||||
- Added zlib_get_coding_type() function which returns the coding type used for
|
||||
output compression. (Moriyoshi)
|
||||
- Added OCIPasswordChange() which allows renewing expired Oracle users. (Maxim)
|
||||
- Added memory_get_usage(). Only available when PHP is configured with
|
||||
--enable-memory-limit. (Andrey)
|
||||
- Added improved JPEG 2000 support for getimagesize(). (Marcus, Adam Wright)
|
||||
- Added XBM and WBMP support for getimagesize(). (Marcus)
|
||||
- Added KOI8-R, CP866, and CP1251 support for htmlentities().
|
||||
(Antony Dovgal, Moriyoshi)
|
||||
- Added domdocument->free() to free XML-documents from memory. (Rob Richards)
|
||||
- Fixed a bug in error reporting with the CLI for start-up errors. (Derick)
|
||||
- Fixed spurious fsync calls during socket communication. (Sascha)
|
||||
- Fixed a possible vhost issue in thttpd. (Sascha, dgl@dgl.cx)
|
||||
- Fixed including from HTTP URLs. (Sascha)
|
||||
- Fixed a lot of memory leaks in domxml. (Rob Richards, Chregu)
|
||||
- Fixed a bug in GD's truecolor TTF handling. (Derick)
|
||||
- Fixed several 64-bit problems. (Dave)
|
||||
- Fixed several errors in hwapi extension. Objects weren't handled properly.
|
||||
(Uwe)
|
||||
- Fixed bug #23788 (str|preg_replace() clobber the array elements). (Ilia)
|
||||
- Fixed bug #23765 (file uploads ignored due to case sensitivity). (Sara)
|
||||
- Fixed bug #23738 (ifx_copy_blob() crash). (Jani)
|
||||
- Fixed bug #23661 (mysql_fetch_array() gives no warning when an invalid
|
||||
argument was passed as result_type). (Derick)
|
||||
- Fixed bug #23619 (set_error_handler() registered handler not called for
|
||||
object instances). (Jani, waboring@qualys.com)
|
||||
- Fixed bug #23606 (Unable to build --with-db4 (db4.1.25)). (Marcus)
|
||||
- Fixed bug #23567 (pfsockopen() returns dead connections). (Wez)
|
||||
- Fixed bug #23539 (curl_exec() produces strange results). (daniel@haxx.se)
|
||||
- Fixed bug #23527 (PostScript Type 1 fonts do not render properly).
|
||||
(nid@home.se, Ilia)
|
||||
- Fixed bug #23402 (crash with improper use of mssql_bind()). (Frank)
|
||||
- Fixed bug #23371 (configure falsely detects c-client using SSL). (Jani)
|
||||
- Fixed bug #23340 (fopen on multiple URLs causes memory corruption). (Wez)
|
||||
- Fixed bug #23298 (serialize cuts off floats & doubles). (Ilia, Marcus)
|
||||
- Fixed bug #23232 (safe_mode does not honor PHP_AUTH_* in apache2). (Ilia)
|
||||
- Fixed bug #23225 (money_format() didn't handle erroneous return of strfmon).
|
||||
(Ilia, marcot@tabini.ca)
|
||||
- Fixed bug #23201 (set_file_buffer() crashes with stdio streams). (Ilia)
|
||||
- Fixed Bug #23188 (CDB databases created with 'c' mode do not work). (Marcus)
|
||||
- Fixed bug #23187 (memory leaks in sybase_connect/sybase_pconnect). (Ilia)
|
||||
- Fixed bug #23162 (user_error() crashs if error message > 1024 bytes).
|
||||
(Jay, Marcus, Moriyoshi)
|
||||
- Fixed bug #23152 ($http_response_header empty on invalid URLs). (Ilia)
|
||||
- Fixed bug #23102 (integer overflow in exif_iif_add_value()). (Ilia)
|
||||
- Fixed bug #23099 (ext/interbase: libgds.so: undefined reference to 'crypt').
|
||||
(Jani)
|
||||
- Fixed bug #23093 (highlight_string() crashed with __FUNCTION__). (Jani)
|
||||
- Fixed bug #23080 (socket_strerror() crashes on win32). (Moriyoshi)
|
||||
- Fixed bug #23071 (when DST in effect, date("T") crashed PHP).
|
||||
(Scott MacVicar, Jani)
|
||||
- Fixed bug #23069 (tempnam creates readonly file [win32]). (Wez)
|
||||
- Fixed bug #23009 (pg_select with timestamp). (Marcus, Jay)
|
||||
- Fixed bug #23008 (ldap_start_tls() not available on Windows). (Edin)
|
||||
- Fixed bug #23004 (When ftp_close() is called, send QUIT to the ftp server).
|
||||
(Ilia)
|
||||
- Fixed bug #22989 (sendmail not found by configure). (igyu@ionsphere.org)
|
||||
- Fixed bug #22987 (missing perror() check in configure). (Jani)
|
||||
- Fixed bug #22965 (Crash in gd lib's ImageFillToBorder()). (Ilia)
|
||||
- Fixed bug #22939 (crash in imap_header_info()). (Ilia)
|
||||
- Fixed bug #22844 (Changing bool value via -d or ini_set(), On would be Off).
|
||||
(Ilia)
|
||||
- Fixed bug #22786 (Crash when trying to call DomAttribute's
|
||||
set_namespace method). (Chregu)
|
||||
- Fixed bug #22775 (Fatal errors exit with status 0 with CGI/CLI). (Jani)
|
||||
- Fixed bug #22774 (PHP crashes when exiting (long XML doc)). (Rob Richards)
|
||||
- Fixed bug #22751 (Compile error in gdcache.c when external libgd is used).
|
||||
(Jani)
|
||||
- Fixed bug #22721 (Poor file() performance on systems without mmap). (Wez)
|
||||
- Fixed bug #22709 (Crash in interbase when database unavailable).
|
||||
(Vladimir Michl)
|
||||
- Fixed bug #22681 (Crash when reading from invalid file pointer). (Ilia)
|
||||
- Fixed bug #22672 (User not logged under Apache2). (Ian)
|
||||
- Fixed bug #22616 (Wrong order of -lssl and -lcrypto with IMAP). (Jani)
|
||||
- Fixed bug #22613 (imagettfbox() does not add the kerning distance to the
|
||||
running position). (Ilia)
|
||||
- Fixed bug #22585 (Do not terminate the script on minor errors). (Ilia)
|
||||
- Fixed bug #22550 (overflow protection for upload_max_filesize ini option).
|
||||
(Ilia)
|
||||
- Fixed bug #22544 (writing transparency to truecolor png images). (Ilia)
|
||||
- Fixed bug #22538 (failed stat on stdio/stdin/stderr streams). (Wez, Ilia)
|
||||
- Fixed bug #22530 (append_child does not unlink node). (Chregu)
|
||||
- Fixed bug #22520 (mcrypt_generic_deinit() was not available on Windows).
|
||||
(Edin)
|
||||
- Fixed bug #22508 (Added protection against circular HTML redirects). (Ilia)
|
||||
- Fixed bug #22473 (ISAPI Secure Server variables not available).
|
||||
(Christian Swoboda)
|
||||
- Fixed bug #22402 (opening of ftp for read/write could fail due to invalid
|
||||
return code handling). (Ilia)
|
||||
- Fixed bug #22384 (FNM_CASEFOLD is not available). (Hartmut)
|
||||
- Fixed bug #22382 (fgetcsv() did not handle \" correctly). (Ilia)
|
||||
- Fixed bug #22376 (wrong httpd.conf modified when using INSTALL_ROOT). (Jani)
|
||||
- Fixed bug #22363 (combinations of fwrite(), fread() and fseek() produce
|
||||
unexpected results). (Wez)
|
||||
- Fixed bug #22355 (PHP would remove folding from Subject & To fields). (Ilia)
|
||||
- Fixed bug #22330 (overloaded strrpos() gives wrong results).
|
||||
(david@santinoli.com, Moriyoshi)
|
||||
- Fixed bug #22312 (crash on failed connection when curl_getinfo() was called).
|
||||
(Phil Oleson <poleson@verio.net>)
|
||||
- Fixed bug #22308 (optimized passthru, code is now ~40 times faster). (Ilia)
|
||||
- Fixed bug #22306 (pg_lo_seek($h, 0, PGSQL_SEEK_SET) succeeds but
|
||||
returns false). (Jani)
|
||||
- Fixed bug #22301 (htmlspecialchars() crashes Apache on Tru64). (Ilia)
|
||||
- Fixed bug #22299 (gethostbyname() with non-existing domain crashed on MacOSX).
|
||||
(Jani)
|
||||
- Fixed bug #22283 (possible crash when opening relative URLs). (Ilia)
|
||||
- Fixed bug #22238 (stream_select() clobbers fifos under win9x). (Wez)
|
||||
- Fixed bug #22234 (copy() fails if source file has 0 length). (Moriyoshi)
|
||||
- Fixed bug #22227 (printf() field limiters broke between 4.2.3 and 4.3.0).
|
||||
(Moriyoshi)
|
||||
- Fixed bug #22224 (implode() changes object references in array). (Moriyoshi)
|
||||
- Fixed bug #22221 (bad rows count in the result object for postgresql). (Marc)
|
||||
- Fixed bug #22207 (e notation in *printf would be missing a 0 when there is
|
||||
no exponent). (Ilia)
|
||||
- Fixed bug #22220 ("php_admin_value open_basedir none" does not work). (Jani)
|
||||
- Fixed bug #22191 (frontbase build broken with old version of frontbase).
|
||||
(Ilia)
|
||||
- Fixed bug #22187 (spprintf function did not handle floats correctly). (Ilia)
|
||||
- Fixed bug #22149 (incorrect insertion of session id when tabs are used to
|
||||
separate tag elements). (Ilia)
|
||||
- Fixed bug #22141 (removed undocumented Boyer str_replace() method). (Sara)
|
||||
- Fixed bug #22103 (Added gdImageEllipse and replaced old gdImageFilledEllipse
|
||||
with a better implementation). (Pierre)
|
||||
- Fixed bug #22088 (array_shift() left next index to be +1 too much). (Jani)
|
||||
- Fixed bug #22083 (MySQL charset directory problem on Windows). (Edin)
|
||||
- Fixed bug #22059 (ftp_chdir() causes segfault). (Sara)
|
||||
- Fixed bug #22048 (crash in imap_header() when the e-mail contains an
|
||||
abnormally large number of special characters). (Ilia)
|
||||
- Fixed bug #22042 (pg_result_seek() would never seek to the 1st row in the
|
||||
result due to always seeking to row next to the one requested). (Ilia)
|
||||
- Fixed bug #22031 (Made curl_write() & curl_write_header() binary safe).
|
||||
(Ilia)
|
||||
- Fixed bug #22022 (Crash in imap_mail_compose() if the body is an empty array).
|
||||
(Ilia)
|
||||
- Fixed bug #22017 (date() does not support negative timestamps on win32).
|
||||
(Ilia)
|
||||
- Fixed bug #22008 (strip_tags() eliminates too much). (Moriyoshi)
|
||||
- Fixed bug #21007 (html_errors off text-only output in phpinfo). (Marcus)
|
||||
- Fixed bug #22004 (Overload extension and _call() breaks classes). (Shane)
|
||||
- Fixed bug #21998 (array_pop() did not reset the current array position).
|
||||
(Jani)
|
||||
- Fixed bug #21978, #21036 (win32 mail(), bcc: gets interpreted as cc:). (Sara)
|
||||
- Fixed bug #21885 (move_uploaded_file() does not ignore open_basedir). (Wez)
|
||||
- Fixed bug #21820 ("$arr['foo']" generates bogus E_NOTICE, should be E_PARSE).
|
||||
(Jani)
|
||||
- Fixed bug #21815 (fpassthru() ignored buffered data but complained anyway).
|
||||
(Wez)
|
||||
- Fixed bug #21809 (select would not always timeout during socket shutdown).
|
||||
(Wez)
|
||||
- Fixed bug #21751 (default output buffer could not be deleted). (Marcus)
|
||||
- Fixed bug #21725 (return behaviour differs between include and require).
|
||||
(Zeev)
|
||||
- Fixed bug #21713 (include remote files leaks descriptors on Solaris). (Wez)
|
||||
- Fixed bug #21708 (ucwords() trouble again). (Moriyoshi)
|
||||
- Fixed bug #21689 (fgetcsv() suppresses some characters before a separator).
|
||||
(Masahiro, Moriyoshi)
|
||||
- Fixed bug #21912, #21676 (getimagesize() failed for remote files). (Wez)
|
||||
- Fixed bug #21597 (made glob() understand Windows paths). (Edin)
|
||||
- Fixed bug #21549 (problem with Ingres II persistent connections). (Jani)
|
||||
- Fixed bug #21544 (Extended checks for where FreeTDS is installed). (Frank)
|
||||
- Fixed bug #21534 (typo in gmp_gcdext() causes incorrect results). (Sara)
|
||||
- Fixed bug #21531 (file_exists() and other filestat functions report errors
|
||||
when the requested file/directory does not exists). (Sara)
|
||||
- Fixed bug #21529 (memory corruption by fsockopen()). (Ilia)
|
||||
- Fixed bug #21525 (bind_textdomain_codeset() now available on Windows). (Edin)
|
||||
- Fixed bug #21523 (number_format() could cause a memory allocation for a
|
||||
negative memory size in situations where the sprintf implementation of the
|
||||
host system generated less decimal places than were requested). (Wez)
|
||||
- Fixed bug #21518 (imagecreatefromstring() crashed with invalid image files).
|
||||
(Ilia)
|
||||
- Fixed bug #21511 (config.status warning). (Jani)
|
||||
- Fixed bug #21498 (mysql_pconnect connection problems). (Georg)
|
||||
- Fixed bug #21453 (improper handling of non-terminated < by strip_tags()).
|
||||
(Ilia)
|
||||
- Fixed bug #21445 (gd unable to open fonts). (Ilia)
|
||||
- Fixed bug #21443 (improper handling of ? surrounded by spaces
|
||||
in get_browser()). (Ilia)
|
||||
- Fixed bug #21442 (crash in mail() on Windows when 1st parameter is empty).
|
||||
(Edin)
|
||||
- Fixed bug #21410 (fixed handling of NULL or "" files on Win32). (Ilia)
|
||||
- Fixed bug #21378 (COM code crashes after update 4.2.1 to 4.3.0). (Harald)
|
||||
- Fixed bug #21338 (html_entity_decode() crashed when "" is passed). (Ilia)
|
||||
- Fixed bug #21310 (Solaris has issues with getcwd() needing read permissions
|
||||
on directories instead of just execute). (Wez, jflemer)
|
||||
- Fixed bug #21297 (in CLI/CGI on the #! it would leave a \n when the code
|
||||
encounters \r\n). (Ilia)
|
||||
- Fixed bug #21268 (session_decode() returned FALSE on success). (Ilia)
|
||||
- Fixed bug #21267 (opening URLs that result in redirection to a relative
|
||||
path was failing). (Ilia)
|
||||
- Fixed bug #21229 (missing 3rd argument to php_module_startup). (Ilia)
|
||||
- Fixed bug #21228 (broken check for ob_gzhandler and made ob_start() return
|
||||
the correct value). (Ilia)
|
||||
- Fixed bug #21226 (parse_url handling of urls without a path). (Ilia)
|
||||
- Fixed bug #21224 (apache configure fails when using --enable-versioning).
|
||||
(Jani)
|
||||
- Fixed bug #21169 (Compile Failure and lots of warnings on UnixWare). (Derick)
|
||||
- Fixed bug #21131 (fopen() with mode 'a+' and rewind() doesn't work). (Wez)
|
||||
- Fixed bug #20857 (snmpset() failed always, patch by: rs@epost.de). (Jani)
|
||||
- Fixed bug #20802 (PHP would die silently when memory limit reached). (Ilia)
|
||||
- Fixed bug #20715 (odbc could not be compiled as shared extension). (Jani)
|
||||
- Fixed bug #20641 (Numeric/decimal datatype overflow in ext/interbase
|
||||
on Win32). (Daniela)
|
||||
- Fixed bug #20503 (imagesetbrush() not available on Windows). (Edin)
|
||||
- Fixed bug #20282 (COM memory leak). (Harald)
|
||||
- Fixed bug #20256 (snprintf() not defined on some systems). (Jani)
|
||||
- Fixed bug #19919 (crash in sapi_apache_header_handler under heavy load).
|
||||
(George)
|
||||
- Fixed bug #19795 (Problems with strnatcmp() / strnatcasecmp()). (Moriyoshi)
|
||||
- Fixed bug #17868 (multiple <!--include--> used to include PHP files crashes).
|
||||
(Ilia)
|
||||
- Fixed bug #17448 (Print the message when OCI_SUCCESS_WITH_INFO is returned).
|
||||
(Maxim)
|
||||
- Fixed bug #17098 (make Apache2 aware that PHP scripts should not be cached).
|
||||
(Ilia)
|
||||
- Fixed bug #16798 (Compile failure with LOB support for Oracle version < 8.1).
|
||||
(Maxim)
|
||||
- Fixed bug #14532 (fixed connection_status() to return 2 for timeouts). (Jani)
|
||||
- Fixed bug #14245 ('make install' fails on AIX when using --with-apxs). (Jani)
|
||||
- Fixed bug #13757 (CGI: passing query string on command line broken). (Shane)
|
||||
- Fixed bug #13561 (--without-pear disabled phpize/php-config install). (Jani)
|
||||
- Fixed bug #13551 (bcmath functions applying scale incorrectly). (Sara)
|
||||
|
||||
17 Feb 2003, Version 4.3.1
|
||||
- Fixed serious security vulnerability in CGI SAPI. (Shane)
|
||||
|
||||
27 Dec 2002, Version 4.3.0
|
||||
- If you don't specify building any other SAPI "make install" will install the
|
||||
CGI SAPI binary in {PREFIX}/bin/php. If you want to install CLI SAPI in that
|
||||
location use "make install-cli" after "make install" or add --disable-cgi
|
||||
to your configure options. In the Windows distribution CLI SAPI is included
|
||||
in the "cli" folder. (Edin)
|
||||
- Removed extensions: (Jan, Jani, Sebastian)
|
||||
. ext/aspell
|
||||
. ext/ccvs
|
||||
. ext/icap
|
||||
. sapi/fastcgi
|
||||
. sapi/fhttpd
|
||||
- Moved extensions to PECL (http://pear.php.net/): (James, Derick, George)
|
||||
. ext/vpopmail
|
||||
. ext/cybermut
|
||||
. ext/cybercash
|
||||
- Make PHP_AUTH_* variables not available in safe mode under Apache when an
|
||||
external basic auth mechanism is used. (Philip)
|
||||
- Aliased dba_popen() to dba_open() until 4.3.2 when persistent STDIO streams
|
||||
are introduced. (Andrei)
|
||||
- Fixed a security bug in the bundled MySQL library. (Georg, Stefan)
|
||||
- ZLIB extension is now built-in in the Windows distribution.
|
||||
External extension (php_zlib.dll) has been removed. (Edin)
|
||||
- Fixed a bug in ISO-8601 week calculation
|
||||
- Fixed a crash when using invalid color index with imagecolortransparent().
|
||||
(Pierre-Alain Joye)
|
||||
- Fixed bug #20987 (no handling for client certificates). (Ilia)
|
||||
- Fixed bug #21039 (crash when not supplying an IV to mcrypt_generic_init).
|
||||
(Derick)
|
||||
- Fixed bug #20936 (openssl_pkey_get was broken). (jeroen@derks.it, Wez)
|
||||
- Fixed bug #20927 (wordwrap crash). (Ilia)
|
||||
- Fixed bug #20796 (when register_globals is on & arrays with same names are
|
||||
passed via get/post/cookie the data inside $_GET/$_POST/$_COOKIE can would be
|
||||
corrupted). (Ilia)
|
||||
- Fixed bug #20725 (if the upload directory cannot be written to, the POST data
|
||||
after the uploaded file is lost). (Ilia)
|
||||
- Fixed bug #20865 (array_key_exists() fails to find NULL key). (Ilia)
|
||||
- Fixed bug #20812 (ftp_get returned NULL on success, instead of TRUE). (Ilia)
|
||||
- Fixed bug #20785 (crash when using pdf_open_memory_image() to load a
|
||||
true-color image). (Ilia)
|
||||
- Fixed a crash when converting between true-color images (png/jpeg) and
|
||||
gd1/gd2 image formats, png/jpeg -> gd1/gd2 -> png/jpeg conversion now
|
||||
works correctly. (Ilia, Pierre-Alain Joye)
|
||||
- Fixed a memory leak in the bundled GD library inside
|
||||
gdImageTrueColorToPalette(). (Ilia)
|
||||
- Fixed bug #12776 (array_walk crash). (Moriyoshi)
|
||||
- Fixed bug #20934 (htmlspecialchars returns latin1 from UTF-8). (Moriyoshi)
|
||||
- Fixed bugs #20270, #15702, #18600 (segfaults in ext/java). (Tony J. White)
|
||||
- Made bcmath extension thread safe. (Sander)
|
||||
- Fixed bug #19566 (get_declared_classes() segfaults). (Moriyoshi, Marcus, Andi)
|
||||
- Fixed bug #20381 (array_merge_recursive mangles input arrays). (Moriyoshi)
|
||||
- Added -n command switch to cli and cgi version which allows to skip php.ini
|
||||
parsing at startup. (Marcus, Wez)
|
||||
- Fixed bug #19689 (absolute paths like /test/dir/ not working correctly).
|
||||
(Ilia)
|
||||
- Added "neutral" language entry to mbstring spec. (Moriyoshi)
|
||||
- Changed bundled gd library to consider php.ini option memory_limit. (Marcus)
|
||||
- Modified log() to accept multiple bases. (Jason)
|
||||
- Fixed bugs #16190/18746 (ext/db: flatfile support with windows). (Marcus)
|
||||
- Added gd_info() which returns an array of gd support information. (Marcus)
|
||||
- Implemented features/changes requested in Bug #16960 (Timm):
|
||||
. Added a new function sybase_unbuffered_query()
|
||||
. Added a new function sybase_fetch_assoc()
|
||||
. Added sybase_set_message_handler() which enables users to handle
|
||||
server messages in a callback function
|
||||
. Added an ini entry for deadlock retries - retrying deadlocks can cause
|
||||
transaction state to break (sybct.deadlock_retry_count,
|
||||
defaults to -1 "forever").
|
||||
. Fixed sybase_fetch_object() not to return objects with numeric members
|
||||
. Fixed issues with identical fieldnames
|
||||
. Made sybase_fetch_*() functions return correct datatypes
|
||||
. Made phpinfo() section more verbose
|
||||
. Made sybase_query() error messages more verbose
|
||||
- Fixed bug #19935 (made OpenSSL file system operations abide by safe_mode
|
||||
& open_basedir restrictions). (Ilia)
|
||||
- Fixed bug #18868 (improved the check for availability of realpath()). (Ilia)
|
||||
- Fixed width/height detection of bmp images using getimagesize() function on
|
||||
big endian systems and added code to retrieve bmp bit depth. (Ilia)
|
||||
- Fixed bug #20035 (line counting error when script starts with #! in
|
||||
cgi/cli/fastcgi sapis). (Ilia)
|
||||
- Fixed bug #20235 (incorrect handling of symlinks on ZTS build). (Ilia)
|
||||
- Added sanity checks to headers_sent() & image_type_to_mime_type(). (Ilia)
|
||||
- Added an aditional parameter to the jdtojewish() function which makes
|
||||
the function return the symbolic hebrew name. (Moshe Doron, Derick)
|
||||
- Fixed bug #20169 (implode() clobbers first argument). (Moriyoshi)
|
||||
- Improved dba extension (Marcus)
|
||||
. Added dba_handlers() that returns an array of installed handlers and
|
||||
dba_list() that returns an associative array of open database files.
|
||||
. Added bundled cdb support wich can be activated by --with-cdb without a
|
||||
path. The bundled version supports cdb_make that allows writing cdb files.
|
||||
. Added optional skip parameter to dba_fetch() to support multiple key-value
|
||||
pairs with the same key for cdb handler.
|
||||
. Added locking for those handlers that do not have their own locking.
|
||||
. Added support for magic_quotes_runtime php.ini option.
|
||||
. Added flatfile support what finally makes ext/db deprecated.
|
||||
- Added imagerotate() which is available only when bundled libgd is used.
|
||||
(Pierre-Alain Joye, Ilia)
|
||||
- Fixed bug #17497 (mssql extension crashes if magic_quotes_runtime is on).
|
||||
(Sterling)
|
||||
- Remove $_FILES from $_REQUEST (import_request_variables is not modified),
|
||||
this didn't work properly in the first place, and added confusion. (Sterling)
|
||||
- Fixed the socket_read() function on win32 to work in normal mode (reading to
|
||||
the end of a line), as well as binary mode. (Sterling)
|
||||
- Fixed bug #20110 (added sanity check to prevent include/require functions
|
||||
from trying to include directories). (Ilia)
|
||||
- Fixed bug #20108 (segmentation fault on printf("%1.1s", "string")). (Ilia)
|
||||
- Added dbx_escape_string() function to dbx module. (Marc)
|
||||
- Added Oracle (oci8) support to dbx module. (Marc)
|
||||
- Updated FDF extension to work with Adode fdftk 5.0. (Hartmut)
|
||||
- Added mb_strtolower() and mb_strtoupper(). (Moriyoshi)
|
||||
- Fixed an infinite loop in setlocale() when only invalid locale names
|
||||
were passed in the array. (patch by Pal Loberg, pallo@initio.no)
|
||||
- Fixed bugs #19156 and #19544 (COM extension leaks memory and keeps
|
||||
components referenced). (Harald)
|
||||
- Added fribidi_get_charsets() and fribidi_charset_info() functions. (Tal)
|
||||
- Added Oracle TIMESTAMP type to oci8 extension. (Thies)
|
||||
- Fixed fgets($fp) to read until EOL when length parameter is not set. (Wez)
|
||||
- Changed registry entries under "HKLM\SOFTWARE\PHP\Per Directory Values" to
|
||||
work also with administrative directives such as safe_mode, open_basedir,
|
||||
etc. (Claudio Felber)
|
||||
- Added str_word_count() function which counts words inside a string. (Ilia)
|
||||
- Added PGSQL_CONNECT_FORCE_NEW option to pg_connect() (Yasuo)
|
||||
- Added ICONV_IMPL and ICONV_VERSION constants to iconv extension to
|
||||
indicate which iconv implementation is used. (Moriyoshi)
|
||||
- Fixed bug #4232 (Added %e & %E support to printf/sprintf). (Ilia)
|
||||
- Fixed bug #17580 (Allow ini parser to parse files >16K). (Ilia)
|
||||
- Fixed bug #19649 (Sanity checks for browscap.ini parser). (Ilia)
|
||||
- Added experimental patch to address problem with floats on various locales.
|
||||
(Bug #17079). (Ilia)
|
||||
- Fixed bug #19280 (imap_header fails with many To: addresses). (Ilia)
|
||||
- Added mb_regex_set_options(). The Options parameters of various mbregex
|
||||
functions are now deprecated. (Moriyoshi)
|
||||
- Fixed bug #19482 (Segfault with PCRE and locale). (Andrei)
|
||||
- Made ImageTruecolorToPalette() in bundled GD2 library actually work. (Rasmus)
|
||||
- Fixed ImageCopy() in bundled GD2 library to handle copying from truecolor to
|
||||
palette-based. (Wez, Rasmus)
|
||||
- Added read-only GIF support for bundled GD2 library. (Rasmus)
|
||||
- Made several adjustments to xslt extension (David Viner, Lehnar, Melvyn)
|
||||
. Added xslt_set_object and xslt_setopt function
|
||||
. Changed backend interaction with Sablotron library
|
||||
. Fixed leak with error_print
|
||||
. Made xslt_make_array() always set NULL on last index to signal array end.
|
||||
- Changed the glue argument in implode() to be optional. If not specified,
|
||||
defaults to "". (Sterling)
|
||||
- Fixed fields argument to contain correct info for xslt_set_error_handler().
|
||||
(Patch by Lenar Lohmus)
|
||||
- Added --with-config-file-scan-dir compile-time switch which specifies a
|
||||
directory which will be scanned for *.ini files. (Rasmus)
|
||||
- Added ob_get_clean() and ob_get_flush(). (Yasuo)
|
||||
- Added ftp_ssl_connect() to ext/ftp for FTP over SSL support. (Stefan Esser)
|
||||
- Made a few additions and changes to Apache 2 sapi. (Ilia)
|
||||
. Added apache_response_headers(), apache_note(), apache_getenv() and
|
||||
apache_setenv() functions.
|
||||
. Added more detailed error reporting to apache_lookup_uri() and virtual().
|
||||
. Renamed getallheaders() to apache_request_headers() and made an alias for BC.
|
||||
. Added php_apache_sapi_getenv() and php_apache_sapi_get_stat().
|
||||
. Added syntax-highlighting handling (.phps)
|
||||
- Fixed strstr(), strchr() and strrchr() to be binary safe. (Andrey)
|
||||
- Added array_diff_assoc() and array_intersect_assoc(). (Andrey)
|
||||
- Fixed bug #17825 (ob_start() chunk size option didn't work well). (Yasuo)
|
||||
- Fixed output buffer infinite loop when buffer_size became 0. (Marcus, Wez)
|
||||
- Added getopt() for parsing command line options and arguments. (Jon)
|
||||
- Added pg_fetch_assoc(), pg_fetch_all(), pg_ping(), pg_meta_data(), pg_convert(),
|
||||
pg_insert(), pg_select(), pg_update(), pg_delete(), pg_result_seek(),
|
||||
pg_unescape_bytea(), pg_get_notify() and pg_get_pid(). (Yasuo)
|
||||
- Fixed bug #17281 (Sanity checks for encoding sessions). (Ilia)
|
||||
- Fixed bug #16995 and #19392 (Prevent crash if $HTTP_SESSION_VARS != ARRAY).
|
||||
(Ilia)
|
||||
- Fixed bug #19292 (open_basedir restriction problem). (Rasmus)
|
||||
- Fixed bug #19366 (gdImageFill crashes when x & y are outside of
|
||||
the image's boundries). (Ilia)
|
||||
- Fixed bug #13936 (__FILE__ constant didn't contain full path). (Ilia)
|
||||
- PHP now has a new stream system that allows it to do some clever stuff with
|
||||
fopen() and fsockopen(). As a result:
|
||||
. URL wrappers natively supports https:// URLs if you have compiled
|
||||
OpenSSL support into PHP (shared extension does not support this).
|
||||
. Added support for fopen("ftps://...", ...) which allows to connect to FTP
|
||||
servers via SSL. (Stefan Esser)
|
||||
. fsockopen() adds support for ssl:// and tls:// connections via TCP/IP
|
||||
. copy($srcfilename, $destfilename) can now be used with URL wrappers
|
||||
. zlib wrappers/streams can be used even on systems without fopencookie()
|
||||
. Changed 'zlib:' fopen wrapper to 'compress.zlib://' and deprecate
|
||||
'zlib:' to avoid ambiguities when filenames have ':' characters. (Wez)
|
||||
. Added 'compress.bzip2://' stream and wrapper support.
|
||||
. Added user-space streams - it is now possible to define a class in PHP
|
||||
code and register it as a URL wrapper. (stream_register_wrapper)
|
||||
. Most extensions now support streams when passing files, which means
|
||||
that those extensions will now also support URL wrappers. (Wez)
|
||||
. Added URL-wrapper support to exif. (Marcus)
|
||||
. Added memory stream support. (Marcus)
|
||||
. Renamed:
|
||||
socket_set_timeout() -> stream_set_timeout()
|
||||
socket_set_blocking() -> stream_set_blocking()
|
||||
set_file_buffer() -> stream_set_write_buffer()
|
||||
socket_get_status() -> stream_get_meta_data()
|
||||
As these functions can (in theory) work on any type of stream. (Wez)
|
||||
. Raw POST data is now available as "php://input" stream. (Hartmut)
|
||||
. fopen("php://output", "wb") returns a stream that writes to the output
|
||||
buffer (like echo and print). (Wez)
|
||||
. Added stream_context_create(), stream_context_set_params() and
|
||||
stream_context_set_option and added an optional fourth parameter to
|
||||
fopen() which accepts a stream context. Contexts allow sharing of
|
||||
information between streams (a kind of "session") and setting
|
||||
notification callbacks. (Wez)
|
||||
. Made the "User-Agent" header sent by http:// and https:// wrappers
|
||||
configurable in php.ini or via a stream context. (Sterling)
|
||||
. Added stream_filter_prepend() and stream_filter_append() which apply
|
||||
a filter to either the top or the bottom of a stream filter stack.
|
||||
Implemented "string.rot13" filter as an example; more filters are
|
||||
expected to follow in later releases and other extensions. (Wez)
|
||||
. Added stream_select() which works like socket_select but works on
|
||||
streams returned by fopen(), fsockopen() and pfsockopen() instead. (Wez)
|
||||
. Added STDIN, STDOUT and STDERR constants for CLI sapi reflecting opened
|
||||
streams to their respective standard I/O counterparts. (Edin)
|
||||
. Added php.ini option "auto_detect_line_endings" which enables PHP to
|
||||
detect Macintosh, Unix and Dos end-of-line characters in fgets() and
|
||||
file(). Fixes bugs #16521 and #16708. (Wez)
|
||||
. Fixed include(), require() and GD functions to work with remote files
|
||||
under win32.
|
||||
Fixed bug #18609 (ImageCreateFromJPEG can't fetch from a URL). (Wez)
|
||||
- Fixed bug #18022 (fopen does not work with php://stdin anymore on Solaris).
|
||||
(Wez)
|
||||
- Added php.ini option "default_socket_timeout" to set the timeout limit for
|
||||
PHP network streams. (kalowsky, ilia@prohost.org, Wez)
|
||||
- Added file_get_contents() which returns the contents of a file as a string.
|
||||
This function also supports the URL wrappers. (Wez)
|
||||
- Fixed bug #19595 (Missing functions for GD2 format handling). (Edin)
|
||||
- Fixed bug #19633 (Wrong directories in ext/ldap/config.m4). (Derick)
|
||||
- Fixed bugs #17274 and #19627 (segfault in sem_remove). (Wez)
|
||||
- Added mb_convert_case() function to the mbstring extension which can convert
|
||||
strings between upper, lower and title case using Unicode mappings.
|
||||
Fixed bug #19257 (strtolower & strtoupper does not work for UTF-8 strings).
|
||||
(Wez)
|
||||
- Fixed bug #18521 (htmlentities didn't warn about unsupported charsets). (Wez)
|
||||
- Fixed bug #11643 (Session related, fix SID redefinition). (Ilia)
|
||||
- Fixed bug #18556 (Scripting Engine, problem with locales like tr_TR). (Ilia)
|
||||
- Changed y2k_compliance to default to 1 now. (Sascha)
|
||||
- Added platform independent socket error constants for better error handling. (Jason)
|
||||
- Update output of phpinfo() to use more CSS to reduce the file size, do
|
||||
proper HTML escaping, and make it XHTML compliant. (Colin)
|
||||
- Fixed compile errors in the FriBidi extension (Bug #16414). (Tal)
|
||||
- Fixed bugs #7472, #12120 and #12989 as well as other potential problems
|
||||
with strip_tags() function. (Ilia)
|
||||
- Fixed bugs #17570 and #17957 (Regexps related). (Andrei, Ilia)
|
||||
- Fixed bugs #18167 and #16859 (SEGV with session_decode). (Ilia)
|
||||
- Fixed bugs #19573 and #13472 (Session, XHTML compliance and trans_sid).
|
||||
(Sascha)
|
||||
- Fixed bug #19570 (last character was missing in get_html_translation_table).
|
||||
(Wez)
|
||||
- Upgraded PCRE to version 3.9. (Wez)
|
||||
- Fixed bug in OCIResult() which returned garbage when called on
|
||||
empty result-sets. (Thies)
|
||||
- Added ability to use Perl-style ${n} subpattern references in the
|
||||
replacement string for preg_replace() (bug #18442). (Andrei)
|
||||
- Fixed array_merge_recursive() to avoid problems with merging cyclical
|
||||
arrays (bug #16064). (Andrei)
|
||||
- Made function_exists() work properly with disabled functions. (Andrei)
|
||||
- Added ability to extract() variables as references via OR'able EXTR_REFS
|
||||
flag. (Andrei)
|
||||
- Fixed a build failure with the OCI8 extension on Tru64.
|
||||
(Patch by Michael Mauch, micahel.mauch@gmx.de)
|
||||
- Added --disable-all configure option. (Jani)
|
||||
- Backported debug_backtrace() from ZendEngine2. (Thies)
|
||||
- Added html-free phpinfo() output for CLI. (Jan)
|
||||
- Fixed socket_recvfrom() to be binary safe. (Jason)
|
||||
- Changed mail() to use escape_shell_cmd() to allow multiple extra parameters
|
||||
to the invocation of the mailer as used in the fifth parameter. (Derick)
|
||||
- Changed cURL extension to require cURL version 7.9.8 (Derick)
|
||||
- Added zend_execute_internal which is called like zend_execute but for
|
||||
internal functions. (Thies)
|
||||
- Changed pg_connection_status(), pg_connection_reset(), pg_connection_busy(),
|
||||
pg_result_status() and pg_result_error() to silently return FALSE when
|
||||
resource is not passed to them. (Yasuo)
|
||||
- Fixed some mysql compile failures on 64 bit-OS. (Georg)
|
||||
- Added warnings for deprecated mysql functions:
|
||||
. mysql_create_db()
|
||||
. mysql_drop_db()
|
||||
. mysql_escape_string()
|
||||
- Added XsltObject->result_dump_mem($result) for returning xslt-result directly
|
||||
into a string and XsltObject->result_dump_file($result,$file[,$compression])
|
||||
for dumping into a file. (morus.walter@web.de, chregu)
|
||||
- Made mime_magic and ZIP extensions available on Windows. (Edin)
|
||||
- Added xslt_backend_version() and xslt_backend_name() for getting
|
||||
information about the processor backend. (chregu)
|
||||
- Added ImageColorMatch() and ImageLayerEffect() functions which are only
|
||||
available when using the bundled GD library. (ttoohey)
|
||||
- Made major improvents to the pcntl extension. (Jason)
|
||||
. Greatly improved performance (signal callback mechanism uses ticks)
|
||||
. Implemented object signal callback ability by using array($obj, $method)
|
||||
. Added a restart parameter to pcntl_signal, which allows you to disable
|
||||
the default of system call restarting
|
||||
- Changed DomNode->next_sibling() and DomNode->previous_sibling() to return
|
||||
NULL instead of false (W3C specs). (chregu)
|
||||
- Changed DomNode->insert_before() and DomNode->append_child() to conform to
|
||||
W3C specs (moving not copying nodes, accepting NULL as 2nd param). (chregu)
|
||||
- Added DomNode->set_namespace(uri[,prefix]) (chregu)
|
||||
- Fixed shuffle() to properly generate all possibilities. (Patch provided by
|
||||
Adam <adam@trachtenberg.com>)
|
||||
- Fixed DomNode->insert_before() to behave according to W3C spec
|
||||
ie. new_child is moved, not copied. (chregu)
|
||||
- Added some namespace support with DomNode->add_namespace(uri, prefix)
|
||||
and DomDocument->create_element_ns(uri, nodename) (chregu)
|
||||
- Added optional parameter to DomElement->node_name() for retrieving fully
|
||||
qualified name (ie. namespace prefix). (chregu)
|
||||
- Changed DomNode->child_nodes() to return empty array instead of false if no
|
||||
child nodes are found. (chregu)
|
||||
- Fixed a bug with handling the Expect header. (Patch by ilia@prohost.org)
|
||||
- Fixed a bug in ODBC where closing the module caused a crash in the Windows
|
||||
executable. (kalowsky)
|
||||
- Fixed memory leaks in pack() and unpack(). (Patch by ilia@prohost.org)
|
||||
- Added URLs to error messages which direct to a page describing the error or
|
||||
function in question. (Derick, Wez, Marcus)
|
||||
- Added odbc_data_source() functionality to identify DB ServerName, and a
|
||||
description of it gathered from the DSN. (kalowsky)
|
||||
- Fixed copy() to return TRUE with 0 byte files. (Patch by ilia@prohost.org)
|
||||
- Added ob_list_handlers() which returns an array of all active output
|
||||
handlers. (Marcus)
|
||||
- Added mbstring encoding/decoding "HTML-ENTITIES". (Marcus)
|
||||
- Added parameter 'L' for mb_http_input() to retrieve input encoding as a
|
||||
comma separated string. (Marcus)
|
||||
- Added the ability for declare() compiler modifications to occur globally
|
||||
by using an empty statement. (Jason, Zend Engine)
|
||||
i.e.
|
||||
//Globally enables the ticks modifier for the whole program
|
||||
declare (ticks=1);
|
||||
|
||||
//Enables the ticks modifier for just the lexical block containing
|
||||
//"statement".
|
||||
declare (ticks=1) {
|
||||
statement;
|
||||
}
|
||||
- Brought strtotime() "next" keyword handling in line with documentation and
|
||||
its glibc cousin. (Rasmus)
|
||||
- Fixed str_rot13() to not mangle source string. (Rasmus)
|
||||
- Fixed imap_get_quota() to work with multiple returned resources as per
|
||||
the RFC 2087 and bug #14673. (kalowsky, Sander Steffann)
|
||||
- Added MarkerNote decoding to exif_read_data() for several Cameras. (Marcus)
|
||||
- Disabled zlib.output_compression for "image/" content-type
|
||||
headers which can be changed during script execution. (Stefan)
|
||||
- Added new asynchronous FTP functions. (Stefan)
|
||||
- Added optional 5th parameter to FTP functions to support resuming. (Stefan)
|
||||
- Added optional 2nd parameter to print_r() to make it return the variable
|
||||
representation instead of echoing it. (Derick)
|
||||
- Added mysql_ping(), mysql_real_escape_string(), mysql_character_set_name(),
|
||||
mysql_thread_id(), mysql_stat() and mysql_list_processes(). (Zak, Georg)
|
||||
- Added safe_mode & open_basedir checks for pg_lo_export(). (Yasuo)
|
||||
- Added open_basedir check for pg_lo_import(). (Yasuo)
|
||||
- Fixed infinite recursion crash bug in ticks. (Jason)
|
||||
- Added php.ini option "mysql.connect_timeout" to set the timeout limit for
|
||||
mysql_connect() and mysql_pconnect(). (Georg)
|
||||
- Added optional parameter "flags" to mysql_connect() and mysql_pconnect()
|
||||
which can be used to set usage of idle timeout and different protocols,
|
||||
SSL and compressed. (Georg)
|
||||
- Added automatic rollback to ext/mysql for non committed transactions. (Georg)
|
||||
- Fixed cases where preg_split() incorrectly terminated final element if it
|
||||
contained null bytes. (Andrei)
|
||||
- Added persistent connections/pipelining to thttpd. (Sascha)
|
||||
- Fixed two potential blocking issues in thttpd. (Sascha)
|
||||
- Fixed broken header file detection on Solaris. (Sascha)
|
||||
- Improved nss/socket-related symbol/library detection. (Jani, Sascha)
|
||||
- Made iconv() work well with both libiconv and libgconv. (Moriyoshi, Yasuo)
|
||||
- Fixed socket_set_timeout() on win32. (Jason, Edin, Jani)
|
||||
- Added domxml_node_namespace_uri(). (Rui Lopes)
|
||||
- Fixed win32 memory leak in /ext/sockets that would occur on any error
|
||||
condition. Also fixed host resolution error messages on win32. (Jason)
|
||||
- Added optional 3rd parameter 'recursive' to ftp_rawlist() which will
|
||||
do 'LIST -R' instead of 'LIST'. (Jani)
|
||||
- Changed getimagesize() to always set unknown fields to 0 and added support
|
||||
for iff imagetype. (Marcus)
|
||||
- Added runtime Apache2 thread check to ensure we don't run a non-threaded
|
||||
PHP inside a threaded Apache2 MPM. (Rasmus)
|
||||
- Made getimagesize() and exif_read_data() to return also the mime-type and
|
||||
exif_thumbnail() to return also the image-type. (Marcus)
|
||||
- Added image_type_to_mime_type() which converts image-types to mime-types.
|
||||
(Marcus)
|
||||
- Made GD functions to only exist if they are available in libgd. Now the
|
||||
availability can be tested with function_exists(). (Derick)
|
||||
- Added an optional parameter to the header() function which overrides the HTTP
|
||||
response code. (Derick)
|
||||
- Changed the order of which modules are unloaded to the reverse order of
|
||||
which they were loaded. (Derick, Zend Engine)
|
||||
- Added preliminary SAX-Input support. It's now possible to build a DomDocument
|
||||
with SAX-Events. (chregu)
|
||||
- Bundled GD library 2.0.1 with php (ext/gd/libgd) (Rasmus, Jani, Markus, Edin)
|
||||
- Fixed bzopen() crash in thread-safe mode. (Andrei)
|
||||
- Added better error-messages (3rd parameter) and validating of DTDs (2nd
|
||||
parameter) to domxml_open_mem() and domxml_open_file(). (Christian)
|
||||
- Added domxml_doc_validate() for validating existing DomDocuments with a DTD.
|
||||
(Christian)
|
||||
- Added ability to capture string offsets in preg_match_*() results.
|
||||
(David Brown, Andrei)
|
||||
- Fixed set_error_handler() to accept methods as callbacks and also report
|
||||
invalid callbacks. (Andrei)
|
||||
- Fixed a memory corruption bug in overload extension. (Andrei)
|
||||
- Fixed error handling in fsockopen() on win32. (Jason)
|
||||
- Added win32 support for the timeout parameter of fsockopen(). (Jason)
|
||||
- Fixed shuffle() to provide equal distribution of values. (Andrei)
|
||||
- Added --with-mysql-sock configure option which can be used to override
|
||||
the unix socket location. (e.g. NFS compiles, etc.) (James Cox)
|
||||
- Fixed is_a() to properly work on extension registered classes. (Andrei)
|
||||
- Added new constants: PHP_PREFIX and PHP_SHLIB_SUFFIX. (Stig)
|
||||
- Added pctnl_alarm() function. (Edin)
|
||||
- If zlib.output_compression is enabled and a page is compressed
|
||||
a "Vary: Accept-Encoding" header is now added. (Stefan)
|
||||
- Renamed getallheaders() to apache_request_headers() and kept getallheaders()
|
||||
as an alias to it. Also added apache_response_headers() which returns the
|
||||
current response headers from Apache. (Rasmus)
|
||||
- Added missing AddRef() calls in the COM extension. This should fix weird
|
||||
behaviour (in particular with ADODB). (Harald)
|
||||
- Fixed segfault in version_compare(). (Stig)
|
||||
- Added compressed Flash MX files support to getimagesize(). (Derick)
|
||||
- Added ability to capture string offsets in preg_split() results.
|
||||
(David Brown, Andrei)
|
||||
- Fixed a crash bug in token_get_all(). (Andrei)
|
||||
- Implemented glob() for Unix/Win32. (Hartmut, Edin, Markus)
|
||||
- Added domxml_doc_set_root() to change the root node. (Lukas Schroeder)
|
||||
- Fixed a crash bug in stripslashes() when working in sybase mode. (Rasmus)
|
||||
- Added experimental support for Simplified Chinese, Traditional Chinese and
|
||||
Korean encodings into mbstring. (Rui)
|
||||
- Misc. Win32 mail() enhancements: support 'From:' header (msisolak@yahoo.com),
|
||||
support Bcc header, case-insensitive headers, enhanced error reporting,
|
||||
automatic proper line ending conversion, fixed crash with Cc, fixed buffer
|
||||
overflows with $header. (Markus)
|
||||
- Improved IMAP extension performance. (adam.kauffman@mindspring.com,
|
||||
rjs3@andrew.cmu.edu, Jon)
|
||||
- Added optional 5th parameter to domxml_xslt_process(). When set, profiling
|
||||
information is saved to the specified file. (chregu)
|
||||
- Added MD5 support for crypt() on Windows. (Edin)
|
||||
- Fixed resource bug in LDAP extension. (Stig Venaas)
|
||||
- Fixed crash in output buffering when buffer is overwritten in a callback.
|
||||
(Yasuo)
|
||||
- Added output_add_rewrite_var() and output_remove_rewrite_var() to inject
|
||||
and remove variables from the URL-Rewriter. (Thies)
|
||||
- The Windows build can now be configured more comfortably, for example
|
||||
when dealing with built-in extensions. (Sebastian)
|
||||
- Added large OID value (2^31 to 2^32) support for pg_lo_import(),
|
||||
pg_lo_unlink(), pg_lo_open() and pg_lo_export(). (Yasuo)
|
||||
- Fixed mixing OCIPlogon() and OCINLogon() to not leak Oracle-Sessions. (Thies)
|
||||
- Added php.ini options for EXIF extension to encode and decode Unicode/JIS
|
||||
user comments. (Marcus)
|
||||
- Changed the "-c" CLI/CGI option to allow both 'filename' and
|
||||
'path to php.ini'. (Yasuo)
|
||||
- Added version information to the .dll and .exe files created under Windows.
|
||||
(jtate)
|
||||
- Added __FUNCTION__ and __CLASS__ constants. (Jani, Zend Engine)
|
||||
- Added optional 2nd parameter for pg_result_status() to specify return type.
|
||||
(Yasuo)
|
||||
- Added "log_errors_max_len" php.ini option which controls maximum length for
|
||||
error messages. (Marcus)
|
||||
- Added "ignore_repeated_errors" and "ignore_repeated_source" php.ini options
|
||||
which can be used to disable logging of repeated error messages. (Marcus)
|
||||
- Made pg_last_notice() work correctly. (Yasuo)
|
||||
- Added "pgsql.ignore_notice" and "pgsql.log_notice" php.ini options. (Yasuo)
|
||||
- Added "zlib.output_compression_level" php.ini option. (Stig)
|
||||
- Added support for --with-apxs build on Mac OS X / Darwin. (markonen)
|
||||
- Added support for dynamically loaded extensions on OS X / Darwin.
|
||||
NOTE: This requires Apache 1.3.25 or later. (kalowsky, markonen)
|
||||
- Fixed CR/LF processing in quoted_printable_decode() on Win32. (kir)
|
||||
- Made crack extension available on Win32. Cracklib libraries for Win32 are
|
||||
available at http://www.jtatesoftware.com/cracklib/. (jtate)
|
||||
- Added mysql_info() function. (Jan)
|
||||
- Added mysql_list_processes() and mysql_stat() functions. (Georg)
|
||||
- Fixed memory allocation problem on systems that have iconv() support in libc.
|
||||
(Yasuo)
|
||||
- Made var_dump() handle recursive structures better. (Yasuo, Derick)
|
||||
- Added exif_imagetype() function. (Marcus)
|
||||
- New improved build system. Among other improvements, replaces the slow
|
||||
recursive make with one global Makefile and eases the integration of proper
|
||||
dependencies. Automake is only needed for its aclocal tool. The build
|
||||
process is now more portable and less resource-consuming. (Sascha)
|
||||
|
||||
06 Sep 2002, Version 4.2.3
|
||||
- Disabled the fifth parameter in mail() when safe-mode is turned on. (Derick)
|
||||
- Enable UTF8 modifier support for PCRE on win32. (Wez, Edin)
|
||||
- Enabled strcoll() on win32. (Markus)
|
||||
- Fixed possible ASCII control char injection in mail(). (Stefan Esser)
|
||||
- Fixed a potential crash bug in import_request_variables() (Zeev)
|
||||
- Fixed several problems with directory functions on Windows. (Steph)
|
||||
- Fixed xbithack bug in Apache module. (Rasmus)
|
||||
- Fixed a bug that prevented touch() from working on various platforms. (Steph)
|
||||
- Fixed ob_gzhandler()'s handling of requests that do have the Accept-Encoding
|
||||
header, but do not allow compression. (Zeev)
|
||||
- Fixed several bugs in the multithreaded version that could cause random parse
|
||||
errors, especially on machines with multiple CPUs. (Zeev, Zend Engine)
|
||||
- Fixed a build problem in bcmath. (Alan)
|
||||
- Fixed several bzip2 issues. (Andrei, kalowsky)
|
||||
- Fixed several COM issues. (Harald)
|
||||
- Various exif fixes. (Marcus)
|
||||
- Fixed domxml_xslt_process() and domxml_get_element_by_id() and several
|
||||
other issues in DOMXML. (Christian)
|
||||
- Fixed DOMXML crash on removing previously created attributes. (Christian)
|
||||
- Fixed crash when converting $GLOBALS to an object. (Zeev, Zend Engine)
|
||||
- Fixed ImageCreateFromGD2Part() (Jani)
|
||||
- Fixed a build issue in the IMAP extension under IRIX. (kalowsky)
|
||||
- Fixed a bug in imap_last_error() (Jani)
|
||||
- Various mbstring fixes. (Yasuo, Rui)
|
||||
- Fixed a build problem in the mcal extension. (Jani)
|
||||
- Made MySQL rollback open transactions when the request ends. (Georg)
|
||||
- Fixed a crash in the shutdown order of the ODBC module. (kalowsky)
|
||||
- Fixed PCRE build problems. (troels@arvin.dk)
|
||||
- Fixed a crash in pg_lo_write() (Yasuo)
|
||||
- Fixed posix_isatty() and posix_ttyname(). (Markus)
|
||||
- Fixed accidental pg_lo_import() API change. (Yasuo)
|
||||
- Fixed ereg_replace() crash when the backreference number was greater than the
|
||||
number of captured subpatterns. (oliver@billix.franken.de)
|
||||
- Fixed array_rand() on thread-safe platforms such as Windows. (Edin)
|
||||
- Report the right exit code after a call to exit(). (Edin)
|
||||
|
||||
22 Jul 2002, Version 4.2.2
|
||||
- Fixed serious security vulnerability. (Stefan Esser)
|
||||
22 July 2002, Version 4.2.2
|
||||
- Fixed a security problem in the file upload code, which allows remote parties
|
||||
to crash the webserver's child. On the Sparc architecture this can be used to
|
||||
run arbitrary code. (Stefan)
|
||||
- Fixed the build system for Solaris users. (Sascha)
|
||||
|
||||
13 May 2002, Version 4.2.1
|
||||
- Added safe-mode checks to show_source(), parse_ini_file() and rmdir(). Also
|
||||
@@ -980,18 +48,13 @@ PHP 4 NEWS
|
||||
- ATTENTION!! register_globals defaults to 'off' now !!!
|
||||
- Note: Apache2 support is EXPERIMENTAL.
|
||||
- PostgreSQL functions are renamed, but all old function names are available.
|
||||
Old function names will be available long enough. User can safely use old
|
||||
Old function names will be available long enough. User can safely use old
|
||||
function names. (Yasuo)
|
||||
- Moved ext/mailparse to PECL. See http://thebrainroom.com/opensource/php/
|
||||
for more information and to download the extension. (Wez/Jim)
|
||||
- Fixed pg_last_notice() crash. (Yasuo)
|
||||
- Modified the mysql extension to disable 'LOAD LOCAL' when safe mode is
|
||||
- Modified the mysql extension to disable 'LOAD LOCAL' when safe mode is
|
||||
enabled. (Jason)
|
||||
- Added CLI (command line interface) sapi which is more suitable for writing
|
||||
shell scripts. Some of the differences to CGI sapi are: no HTTP headers,
|
||||
plain text error messages, does not change working directory, have a new -r
|
||||
option which executes a piece of PHP code directly from the commmand line, etc.
|
||||
(Edin)
|
||||
- Fixed HTTP file upload support to handle big files better. (Jani)
|
||||
- Major modifications to the Sockets Extension and its API (Jason):
|
||||
. Fixed numerous bugs.
|
||||
@@ -1181,8 +244,6 @@ PHP 4 NEWS
|
||||
in itself. (Andrei)
|
||||
- Added ini_get_all() function which returns all registered ini entries
|
||||
or entries for the specified extension. (Jani)
|
||||
- Added mailparse_uudecode_all() which extracts all uuencoded attachments.
|
||||
(Wez)
|
||||
- Added support for chinese encodings in htmlentities() and htmlspecialchars().
|
||||
(Patch by Alan Knowles <alan_k@hklc.com> and Wez)
|
||||
- Improved support for autoconf-2.50+/libtool 1.4b+. (Jan Kneschke, Sascha)
|
||||
@@ -1218,7 +279,6 @@ PHP 4 NEWS
|
||||
GMT +0100 and GMT -0100. (Derick)
|
||||
|
||||
10 Dec 2001, Version 4.1.0
|
||||
- Fixed return values for strtok (Bug #13866) (jmoore)
|
||||
- Worked around a bug in the MySQL client library that could cause PHP to hang
|
||||
when using unbuffered queries. (Zeev)
|
||||
- Fixed a bug which caused set_time_limit() to affect all subsequent requests
|
||||
@@ -1283,9 +343,9 @@ PHP 4 NEWS
|
||||
there's no need to import them using the 'global' statement. (Andi & Zeev)
|
||||
- Added vprintf() and vsprintf() functions that allow passing all arguments
|
||||
after format as an array. (Andrei)
|
||||
- Added support for GD2 image type for ImageCreateFromString(). (Jani)
|
||||
- Added support for GD2 image type for ImageCreateFromString() (Jani)
|
||||
- Added ImageCreateFromGD(), ImageCreateFromGD2(), ImageCreateFromGD2part(),
|
||||
ImageGD() and ImageGD2() functions. (Jani)
|
||||
ImageGD() and ImageGD2() functions (Jani)
|
||||
- addcslashes now warns when charlist is invalid. The returned string
|
||||
remained the same (Jeroen)
|
||||
- Added optional extra argument to gmp_init(). The extra argument
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
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. Please have a look at
|
||||
http://cvsbook.red-bean.com/ for more detailed information on CVS.
|
||||
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
|
||||
@@ -84,7 +83,7 @@ For datetime.c:
|
||||
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!
|
||||
@- Fixed memory leak in trim(). (Bob)
|
||||
@- 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
|
||||
|
||||
+9
-14
@@ -7,22 +7,17 @@ WHAT IT IS
|
||||
|
||||
HOW TO USE IT
|
||||
|
||||
Very simple. First, change to the ext/ directory of the PHP 4 sources. If
|
||||
you just need the basic framework and will be writing all the code in your
|
||||
functions yourself, you can now do
|
||||
Very simple. First, cd do directory ext/ in PHP 4 sources. If you just need
|
||||
the basic framework and will be writing all the code in your functions
|
||||
yourself, you can now do
|
||||
|
||||
./ext_skel --extname=module_name
|
||||
|
||||
and everything you need is placed in directory module_name.
|
||||
|
||||
[ Note that GNU awk is likely required for this script to work. Debian
|
||||
systems seem to default to using mawk, so you may need to change the
|
||||
#! line in skeleton/create_stubs to use gawk explicitly. ]
|
||||
|
||||
If you don't need to test the existence of any external header files,
|
||||
libraries or functions in them, the module is already almost ready to be
|
||||
compiled in PHP. Just remove 3 comments in your_module_name/config.m4,
|
||||
change back up to PHP sources top directory, and do
|
||||
and everything you need is placed in directory module_name. In fact, if you
|
||||
don't need to test the existence of any external header files, libraries or
|
||||
functions in them, the module is already almost ready to be compiled in PHP.
|
||||
Just remove 3 comments in your_module_name/config.m4, cd back up to PHP
|
||||
sources top directory, and do
|
||||
|
||||
./buildconf; ./configure --enable-module_name; make
|
||||
|
||||
@@ -38,7 +33,7 @@ HOW TO USE IT
|
||||
FORMAT OF FUNCTION DEFINITIONS FILE
|
||||
|
||||
All the definitions must be on one line. In it's simplest form, it's just
|
||||
the function name, e.g.
|
||||
the function name, ie.
|
||||
|
||||
my_function
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ and not output any error messages.
|
||||
Both functions return SUCCESS or FAILURE depending on the result.
|
||||
|
||||
The auto-conversions are performed as necessary. Arrays, objects, and
|
||||
resources cannot be auto-converted.
|
||||
resources cannot be autoconverted.
|
||||
|
||||
|
||||
Type specifiers
|
||||
@@ -105,20 +105,11 @@ if (zend_parse_parameters(3 TSRMLS_CC, "zbr!",
|
||||
/* Get either a set of 3 longs or a string. */
|
||||
long l1, l2, l3;
|
||||
char *s;
|
||||
/*
|
||||
* The function expects a pointer to a integer in this case, not a long
|
||||
* or any other type. If you specify a type which is larger
|
||||
* than a 'int', the upper bits might not be initialized
|
||||
* properly, leading to random crashes on platforms like
|
||||
* Tru64 or Linux/Alpha.
|
||||
*/
|
||||
int length;
|
||||
|
||||
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
|
||||
"lll", &l1, &l2, &l3) == SUCCESS) {
|
||||
/* manipulate longs */
|
||||
} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
|
||||
"s", &s, &length) == SUCCESS) {
|
||||
"s", &s) == SUCCESS) {
|
||||
/* manipulate string */
|
||||
} else {
|
||||
/* output error */
|
||||
|
||||
@@ -4,9 +4,10 @@ $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, two things are
|
||||
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
|
||||
|
||||
@@ -73,9 +74,28 @@ DEFINING THE NEW EXTENSION
|
||||
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
|
||||
@@ -87,17 +107,13 @@ PHP_ARG_ENABLE(foobar,whether to enable foobar,
|
||||
[ --enable-foobar Enable foobar])
|
||||
|
||||
if test "$PHP_FOOBAR" != "no"; then
|
||||
PHP_NEW_EXTENSION(foobar, foo.c bar.c, $ext_shared)
|
||||
PHP_EXTENSION(foobar, $ext_shared)
|
||||
fi
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
PHP_ARG_ENABLE will automatically set the correct variables, so
|
||||
that the extension will be enabled by PHP_NEW_EXTENSION in shared mode.
|
||||
that the extension will be enabled by PHP_EXTENSION in shared mode.
|
||||
|
||||
The first argument of PHP_NEW_EXTENSION describes the name of the
|
||||
extension. The second names the source-code files. The third passes
|
||||
$ext_shared which is set by PHP_ARG_ENABLE/WITH to PHP_NEW_EXTENSION.
|
||||
|
||||
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.
|
||||
@@ -115,9 +131,8 @@ CREATING SOURCE FILES
|
||||
|
||||
CREATING THE SELF-CONTAINED EXTENSION
|
||||
|
||||
Put config.m4 and the source files into one directory. Then, run phpize
|
||||
(this is installed during make install by PHP 4.0).
|
||||
|
||||
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
|
||||
@@ -142,13 +157,17 @@ ADDING SHARED MODULE SUPPORT TO A 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[,..].
|
||||
automatically be able to use --with-foo=shared or
|
||||
--enable-foo=shared.
|
||||
|
||||
2. In config.m4, use PHP_NEW_EXTENSION(foo,.., $ext_shared) to enable
|
||||
2. In config.m4, use PHP_EXTENSION(foo, $ext_shared) to enable
|
||||
building the extension.
|
||||
|
||||
3. Add the following lines to your C source file:
|
||||
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)
|
||||
|
||||
+61
-191
@@ -2,17 +2,16 @@ An Overview of the PHP Streams abstraction
|
||||
==========================================
|
||||
$Id$
|
||||
|
||||
WARNING: some prototypes in this file are out of date.
|
||||
The information contained here is being integrated into
|
||||
the PHP manual - stay tuned...
|
||||
|
||||
Please send comments to: Wez Furlong <wez@thebrainroom.com>
|
||||
|
||||
Note: this doc is preliminary and is intended to give the reader an idea of
|
||||
how streams work and should be used.
|
||||
|
||||
Why Streams?
|
||||
============
|
||||
You may have noticed a shed-load of issock parameters flying around the PHP
|
||||
code; we don't want them - they are ugly and cumbersome and force you to
|
||||
special case sockets and files every time you need to work with a "user-level"
|
||||
special case sockets and files everytime you need to work with a "user-level"
|
||||
PHP file pointer.
|
||||
Streams take care of that and present the PHP extension coder with an ANSI
|
||||
stdio-alike API that looks much nicer and can be extended to support non file
|
||||
@@ -27,9 +26,7 @@ The main functions are:
|
||||
|
||||
PHPAPI size_t php_stream_read(php_stream * stream, char * buf, size_t count);
|
||||
PHPAPI size_t php_stream_write(php_stream * stream, const char * buf, size_t
|
||||
count);
|
||||
PHPAPI size_t php_stream_printf(php_stream * stream TSRMLS_DC,
|
||||
const char * fmt, ...);
|
||||
count);
|
||||
PHPAPI int php_stream_eof(php_stream * stream);
|
||||
PHPAPI int php_stream_getc(php_stream * stream);
|
||||
PHPAPI char *php_stream_gets(php_stream * stream, char *buf, size_t maxlen);
|
||||
@@ -39,123 +36,20 @@ PHPAPI int php_stream_seek(php_stream * stream, off_t offset, int whence);
|
||||
PHPAPI off_t php_stream_tell(php_stream * stream);
|
||||
|
||||
These (should) behave in the same way as the ANSI stdio functions with similar
|
||||
names: fread, fwrite, fprintf, feof, fgetc, fgets, fclose, fflush, fseek, ftell.
|
||||
names: fread, fwrite, feof, fgetc, fgets, fclose, fflush, fseek, ftell.
|
||||
|
||||
Opening Streams
|
||||
===============
|
||||
In most cases, you should use this API:
|
||||
Ultimately, I aim to implement an fopen_wrapper-like call to do this with
|
||||
minimum fuss.
|
||||
Currently, mostly for testing purposes, you can use php_stream_fopen to open a
|
||||
stream on a regular file.
|
||||
|
||||
PHPAPI php_stream *php_stream_open_wrapper(char *path, char *mode,
|
||||
int options, char **opened_path TSRMLS_DC);
|
||||
PHPAPI php_stream * php_stream_fopen(const char * filename, const char *
|
||||
mode);
|
||||
|
||||
Where:
|
||||
path is the file or resource to open.
|
||||
mode is the stdio compatible mode eg: "wb", "rb" etc.
|
||||
options is a combination of the following values:
|
||||
IGNORE_PATH (default) - don't use include path to search for the file
|
||||
USE_PATH - use include path to search for the file
|
||||
IGNORE_URL - do not use plugin wrappers
|
||||
REPORT_ERRORS - show errors in a standard format if something
|
||||
goes wrong.
|
||||
STREAM_MUST_SEEK - If you really need to be able to seek the stream
|
||||
and don't need to be able to write to the original
|
||||
file/URL, use this option to arrange for the stream
|
||||
to be copied (if needed) into a stream that can
|
||||
be seek()ed.
|
||||
|
||||
opened_path is used to return the path of the actual file opened,
|
||||
but if you used STREAM_MUST_SEEK, may not be valid. You are
|
||||
responsible for efree()ing opened_path. opened_path may be (and usually
|
||||
is) NULL.
|
||||
|
||||
If you need to open a specific stream, or convert standard resources into
|
||||
streams there are a range of functions to do this defined in php_streams.h.
|
||||
A brief list of the most commonly used functions:
|
||||
|
||||
PHPAPI php_stream *php_stream_fopen_from_file(FILE *file, const char *mode);
|
||||
Convert a FILE * into a stream.
|
||||
|
||||
PHPAPI php_stream *php_stream_fopen_tmpfile(void);
|
||||
Open a FILE * with tmpfile() and convert into a stream.
|
||||
|
||||
PHPAPI php_stream *php_stream_fopen_temporary_file(const char *dir,
|
||||
const char *pfx, char **opened_path TSRMLS_DC);
|
||||
Generate a temporary file name and open it.
|
||||
|
||||
There are some network enabled relatives in php_network.h:
|
||||
|
||||
PHPAPI php_stream *php_stream_sock_open_from_socket(int socket, int persistent);
|
||||
Convert a socket into a stream.
|
||||
|
||||
PHPAPI php_stream *php_stream_sock_open_host(const char *host, unsigned short port,
|
||||
int socktype, int timeout, int persistent);
|
||||
Open a connection to a host and return a stream.
|
||||
|
||||
PHPAPI php_stream *php_stream_sock_open_unix(const char *path, int persistent,
|
||||
struct timeval *timeout);
|
||||
Open a UNIX domain socket.
|
||||
|
||||
|
||||
Stream Utilities
|
||||
================
|
||||
|
||||
If you need to copy some data from one stream to another, you will be please
|
||||
to know that the streams API provides a standard way to do this:
|
||||
|
||||
PHPAPI size_t php_stream_copy_to_stream(php_stream *src,
|
||||
php_stream *dest, size_t maxlen);
|
||||
|
||||
If you want to copy all remaining data from the src stream, pass
|
||||
PHP_STREAM_COPY_ALL as the maxlen parameter, otherwise maxlen indicates the
|
||||
number of bytes to copy.
|
||||
This function will try to use mmap where available to make the copying more
|
||||
efficient.
|
||||
|
||||
If you want to read the contents of a stream into an allocated memory buffer,
|
||||
you should use:
|
||||
|
||||
PHPAPI size_t php_stream_copy_to_mem(php_stream *src, char **buf,
|
||||
size_t maxlen, int persistent);
|
||||
|
||||
This function will set buf to the address of the buffer that it allocated,
|
||||
which will be maxlen bytes in length, or will be the entire length of the
|
||||
data remaining on the stream if you set maxlen to PHP_STREAM_COPY_ALL.
|
||||
The buffer is allocated using pemalloc(); you need to call pefree() to
|
||||
release the memory when you are done.
|
||||
As with copy_to_stream, this function will try use mmap where it can.
|
||||
|
||||
If you have an existing stream and need to be able to seek() it, you
|
||||
can use this function to copy the contents into a new stream that can
|
||||
be seek()ed:
|
||||
|
||||
PHPAPI int php_stream_make_seekable(php_stream *origstream, php_stream **newstream);
|
||||
|
||||
It returns one of the following values:
|
||||
#define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */
|
||||
#define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */
|
||||
#define PHP_STREAM_FAILED 2 /* an error occurred while attempting conversion */
|
||||
#define PHP_STREAM_CRITICAL 3 /* an error occurred; origstream is in an unknown state; you should close origstream */
|
||||
|
||||
make_seekable will always set newstream to be the stream that is valid
|
||||
if the function succeeds.
|
||||
When you have finished, remember to close the stream.
|
||||
|
||||
NOTE: If you only need to seek forward, there is no need to call this
|
||||
function, as the php_stream_seek can emulate forward seeking when the
|
||||
whence parameter is SEEK_CUR.
|
||||
|
||||
NOTE: Writing to the stream may not affect the original source, so it
|
||||
only makes sense to use this for read-only use.
|
||||
|
||||
NOTE: If the origstream is network based, this function will block
|
||||
until the whole contents have been downloaded.
|
||||
|
||||
NOTE: Never call this function with an origstream that is referenced
|
||||
as a resource! It will close the origstream on success, and this
|
||||
can lead to a crash when the resource is later used/released.
|
||||
|
||||
NOTE: If you are opening a stream and need it to be seekable, use the
|
||||
STREAM_MUST_SEEK option to php_stream_open_wrapper();
|
||||
This call behaves just like fopen(), except it returns a stream instead of a
|
||||
FILE *
|
||||
|
||||
Casting Streams
|
||||
===============
|
||||
@@ -165,14 +59,14 @@ You need to "cast" the stream into a FILE*, and this is how you do it:
|
||||
FILE * fp;
|
||||
php_stream * stream; /* already opened */
|
||||
|
||||
if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&fp, REPORT_ERRORS) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, &fp, 1) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
The prototype is:
|
||||
|
||||
PHPAPI int php_stream_cast(php_stream * stream, int castas, void ** ret, int
|
||||
show_err);
|
||||
show_err);
|
||||
|
||||
The show_err parameter, if non-zero, will cause the function to display an
|
||||
appropriate error message of type E_WARNING if the cast fails.
|
||||
@@ -189,14 +83,8 @@ if you mix ANSI stdio calls on the FILE* with php stream calls on the stream.
|
||||
If your system has the fopencookie function, php streams can synthesize a
|
||||
FILE* on top of any stream, which is useful for SSL sockets, memory based
|
||||
streams, data base streams etc. etc.
|
||||
|
||||
In situations where this is not desirable, you should query the stream
|
||||
to see if it naturally supports FILE *. You can use this code snippet
|
||||
for this purpose:
|
||||
|
||||
if (php_stream_is(stream, PHP_STREAM_IS_STDIO)) {
|
||||
/* can safely cast to FILE* with no adverse side effects */
|
||||
}
|
||||
NOTE: There might be situations where this is not desireable, and we need to
|
||||
provide a flag to inform the casting routine of this.
|
||||
|
||||
You can use:
|
||||
|
||||
@@ -205,15 +93,10 @@ PHPAPI int php_stream_can_cast(php_stream * stream, int castas)
|
||||
to find out if a stream can be cast, without actually performing the cast, so
|
||||
to check if a stream is a socket you might use:
|
||||
|
||||
if (php_stream_can_cast(stream, PHP_STREAM_AS_SOCKETD) == SUCCESS) {
|
||||
/* it can be a socket */
|
||||
if (php_stream_can_cast(stream, PHP_STREAM_AS_SOCKETD) == SUCCESS) {
|
||||
/* it's a socket */
|
||||
}
|
||||
|
||||
Please note the difference between php_stream_is and php_stream_can_cast;
|
||||
stream_is tells you if the stream is a particular type of stream, whereas
|
||||
can_cast tells you if the stream can be forced into the form you request.
|
||||
The former doesn't change anything, while the later *might* change some
|
||||
state in the stream.
|
||||
|
||||
Stream Internals
|
||||
================
|
||||
@@ -226,10 +109,10 @@ underlying implementation.
|
||||
The php_streams ops struct consists of pointers to methods that implement
|
||||
read, write, close, flush, seek, gets and cast operations. Of these, an
|
||||
implementation need only implement write, read, close and flush. The gets
|
||||
method is intended to be used for streams if there is an underlying method
|
||||
that can efficiently behave as fgets. The ops struct also contains a label
|
||||
for the implementation that will be used when printing error messages - the
|
||||
stdio implementation has a label of "STDIO" for example.
|
||||
method is intended to be used for non-buffered streams if there is an
|
||||
underlying method that can efficiently behave as fgets. The ops struct also
|
||||
contains a label for the implementation that will be used when printing error
|
||||
messages - the stdio implementation has a label of "STDIO" for example.
|
||||
|
||||
The idea is that a stream implementation defines a php_stream_ops struct, and
|
||||
associates it with a php_stream using php_stream_alloc.
|
||||
@@ -238,17 +121,17 @@ As an example, the php_stream_fopen() function looks like this:
|
||||
|
||||
PHPAPI php_stream * php_stream_fopen(const char * filename, const char * mode)
|
||||
{
|
||||
FILE * fp = fopen(filename, mode);
|
||||
php_stream * ret;
|
||||
|
||||
if (fp) {
|
||||
ret = php_stream_alloc(&php_stream_stdio_ops, fp, 0, 0, mode);
|
||||
if (ret)
|
||||
return ret;
|
||||
FILE * fp = fopen(filename, mode);
|
||||
php_stream * ret;
|
||||
|
||||
if (fp) {
|
||||
ret = php_stream_alloc(&php_stream_stdio_ops, fp, 0, 0, mode);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
return NULL;
|
||||
fclose(fp);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
php_stream_stdio_ops is a php_stream_ops structure that can be used to handle
|
||||
@@ -260,7 +143,7 @@ to be passed back to fopen_wrapper (or it's yet to be implemented successor).
|
||||
The prototype for php_stream_alloc is this:
|
||||
|
||||
PHPAPI php_stream * php_stream_alloc(php_stream_ops * ops, void * abstract,
|
||||
size_t bufsize, int persistent, const char * mode)
|
||||
size_t bufsize, int persistent, const char * mode)
|
||||
|
||||
ops is a pointer to the implementation,
|
||||
abstract holds implementation specific data that is relevant to this instance
|
||||
@@ -281,23 +164,10 @@ into a FILE*, so it should be compatible with the mode parameter of fopen().
|
||||
Writing your own stream implementation
|
||||
======================================
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
RULE #1: when writing your own streams: make sure you have configured PHP with
|
||||
--enable-debug.
|
||||
I've taken some great pains to hook into the Zend memory manager to help track
|
||||
down allocation problems. It will also help you spot incorrect use of the
|
||||
STREAMS_DC, STREAMS_CC and the semi-private STREAMS_REL_CC macros for function
|
||||
definitions.
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
RULE #2: Please use the stdio stream as a reference; it will help you
|
||||
understand the semantics of the stream operations, and it will always
|
||||
be more up to date than these docs :-)
|
||||
|
||||
First, you need to figure out what data you need to associate with the
|
||||
php_stream. For example, you might need a pointer to some memory for memory
|
||||
based streams, or if you were making a stream to read data from an RDBMS like
|
||||
MySQL, you might want to store the connection and rowset handles.
|
||||
mysql, you might want to store the connection and rowset handles.
|
||||
|
||||
The stream has a field called abstract that you can use to hold this data.
|
||||
If you need to store more than a single field of data, define a structure to
|
||||
@@ -306,9 +176,9 @@ appropriately), and use the abstract pointer to refer to it.
|
||||
|
||||
For structured state you might have this:
|
||||
|
||||
struct my_state {
|
||||
MYSQL conn;
|
||||
MYSQL_RES * result;
|
||||
struct my_state {
|
||||
MYSQL conn;
|
||||
MYSQL_RES * result;
|
||||
};
|
||||
|
||||
struct my_state * state = pemalloc(sizeof(struct my_state), persistent);
|
||||
@@ -327,36 +197,36 @@ Once you have that part figured out, you can write your implementation and
|
||||
define the your own php_stream_ops struct (we called it my_ops in the above
|
||||
example).
|
||||
|
||||
For example, for reading from this weird MySQL stream:
|
||||
For example, for reading from this wierd mysql stream:
|
||||
|
||||
static size_t php_mysqlop_read(php_stream * stream, char * buf, size_t count)
|
||||
{
|
||||
struct my_state * state = (struct my_state*)stream->abstract;
|
||||
struct my_state * state = (struct my_state*)stream->abstract;
|
||||
|
||||
if (buf == NULL && count == 0) {
|
||||
/* in this special case, php_streams is asking if we have reached the
|
||||
* end of file */
|
||||
if (... at end of file ...)
|
||||
return EOF;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pull out some data from the stream and put it in buf */
|
||||
... mysql_fetch_row(state->result) ...
|
||||
/* we could do something strange, like format the data as XML here,
|
||||
and place that in the buf, but that brings in some complexities,
|
||||
such as coping with a buffer size too small to hold the data,
|
||||
so I won't even go in to how to do that here */
|
||||
if (buf == NULL && count == 0) {
|
||||
/* in this special case, php_streams is asking if we have reached the
|
||||
* end of file */
|
||||
if (... at end of file ...)
|
||||
return EOF;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pull out some data from the stream and put it in buf */
|
||||
... mysql_fetch_row(state->result) ...
|
||||
/* we could do something strange, like format the data as XML here,
|
||||
and place that in the buf, but that brings in some complexities,
|
||||
such as coping with a buffer size too small to hold the data,
|
||||
so I won't even go in to how to do that here */
|
||||
}
|
||||
|
||||
Implement the other operations - remember that write, read, close and flush
|
||||
are all mandatory. The rest are optional. Declare your stream ops struct:
|
||||
|
||||
php_stream_ops my_ops = {
|
||||
php_mysqlop_write, php_mysqlop_read, php_mysqlop_close,
|
||||
php_mysqlop_flush, NULL, NULL, NULL,
|
||||
"Strange MySQL example"
|
||||
php_mysqlop_write, php_mysqlop_read, php_mysqlop_close,
|
||||
php_mysqlop_flush, NULL, NULL, NULL,
|
||||
"Strange mySQL example"
|
||||
}
|
||||
|
||||
Thats it!
|
||||
@@ -370,4 +240,4 @@ connection and then use pefree to dispose of the struct you allocated.
|
||||
You may read the stream->persistent field to determine if your struct was
|
||||
allocated in persistent mode or not.
|
||||
|
||||
vim:tw=78:et
|
||||
vim:tw=78
|
||||
@@ -1,127 +0,0 @@
|
||||
Submitting Patch for PHP
|
||||
========================
|
||||
|
||||
This document describes how to submit a patch for PHP. Since you are
|
||||
reading this document, you are willing to submit a patch for PHP.
|
||||
Please keep reading! Submitting a patch for PHP is easy. The hard
|
||||
part is making it acceptable for inclusion into our repository. :-)
|
||||
|
||||
How to create patch?
|
||||
--------------------
|
||||
We are working with CVS. You need to get CVS source to create a patch
|
||||
that we accept. Visit http://www.php.net/anoncvs.php to get CVS
|
||||
source. You can check out older versions, but make sure you get
|
||||
the default branch (i.e. Do not use -r option when you check out the
|
||||
CVS source)
|
||||
|
||||
Read CODING_STANDARDS file before you start working.
|
||||
|
||||
Now you are ready to create a patch. Modify source to fix a bug in PHP or
|
||||
add a new feature to PHP. After you finished editing, please test your
|
||||
patch. Read README.TESTING for testing.
|
||||
|
||||
After you finish testing your patch, take diff file using
|
||||
"cvs diff > your.patch" command.
|
||||
|
||||
Read README.TESTING for submitting a test script for your patch. This is
|
||||
not strictly required, but it is preferred to submit a test script along
|
||||
with your patch. Making new test script is very easy. It also helps us
|
||||
to understand what you have been fixed or added to PHP.
|
||||
|
||||
|
||||
Tips for creating patch
|
||||
-----------------------
|
||||
If you would like to fix multiple bugs. It is easier for us if you
|
||||
could create 1 patch for 1 bug, but this is not strictly required.
|
||||
Note though that you might get little response, if your patch is
|
||||
too hard to review.
|
||||
|
||||
If you would like change/add many lines, it is better to ask module
|
||||
maintainer and/or internals@lists.php.net, or pear-dev@lists.php.net if
|
||||
you are patching PEAR. Official module maintainers can be found in
|
||||
EXTENSIONS file in PHP source.
|
||||
|
||||
If you are new to CVS (Concurrent Versions System), visit
|
||||
http://cvshome.org/ for details.
|
||||
|
||||
|
||||
Recommended CVS client settings for creating patch file
|
||||
------------------------------------------------------
|
||||
Recommended ~/.cvsrc file setting is:
|
||||
------
|
||||
cvs -z3
|
||||
update -d -P
|
||||
checkout -P
|
||||
diff -u
|
||||
|
||||
------
|
||||
diff -u means:
|
||||
-u Use the unified output format.
|
||||
|
||||
With this CVS setting, you don't have to worry about adding/deleting
|
||||
newlines and spaces.
|
||||
|
||||
|
||||
Check list for submitting patch
|
||||
-------------------------------
|
||||
- Did you run "make test" to check if your patch didn't break
|
||||
other features?
|
||||
- Did you compile PHP with --enable-debug and check the PHP and
|
||||
web server error logs when you test your patch?
|
||||
- Did you build PHP for multi-threaded web servers. (Optional)
|
||||
- Did you create test script for "make test"? (Recommended)
|
||||
- Did you check your patch is unified format and it does not
|
||||
contain white space changes? (If you are not using recommended
|
||||
cvs setting)
|
||||
- Did you update CVS source before you take final patch?
|
||||
- Did you read the patch again?
|
||||
|
||||
|
||||
Where to send your patch?
|
||||
-------------------------
|
||||
If you are patching C source, send the patch to internals@lists.php.net.
|
||||
If you are patching a module, you should also send the patch to the
|
||||
maintainer. Official module maintainers are listed in EXTENSION file
|
||||
in source.
|
||||
|
||||
If you are patching PEAR, send the patch to pear-dev@lists.php.net.
|
||||
|
||||
Please add the prefix "[PATCH]" to your email subject and make sure
|
||||
to include the patch as a MIME attachment even if it is short.
|
||||
|
||||
NOTE: only MIME attachments of type 'text/*' are accepted. The
|
||||
easiest way to acclomplish this, is to make the extension
|
||||
'.txt'.
|
||||
|
||||
Test scripts should be included in the same email.
|
||||
Explain what has been fixed/added/changed by your patch.
|
||||
|
||||
Finally, add the bug Id(s) which can be closed by your patch, if any.
|
||||
|
||||
|
||||
What happens after you submit your patch
|
||||
--------------------------------------
|
||||
If your patch is easy to review and has obviously no side-effects,
|
||||
it might take up to a few hours until someone commits it.
|
||||
|
||||
Because this is a volunteer-driven effort, more complex patches will
|
||||
require more patience on your side.
|
||||
|
||||
If you did not receive any feedback in a few days, please consider
|
||||
resubmitting the description of your patch, along-side with
|
||||
these questions:
|
||||
|
||||
- Is my patch too hard to review? Because of which factors?
|
||||
- Should I split it up in multiple parts?
|
||||
- Are there any unwanted whitespace changes?
|
||||
|
||||
|
||||
What happens when your patch is applied?
|
||||
----------------------------------------
|
||||
Your name will be included together with your email address in the CVS
|
||||
commit log. If your patch affects end-users, a brief description
|
||||
and your name might be added to the NEWS file.
|
||||
|
||||
|
||||
|
||||
Thank you for submitting patch for PHP!
|
||||
-307
@@ -1,307 +0,0 @@
|
||||
[IMPORTANT NOTICE]
|
||||
------------------
|
||||
Do _not_ ask to developers why some or all tests are failed under
|
||||
your environment! Let us know if you find why it fails. Thank you.
|
||||
|
||||
|
||||
[Testing Basics]
|
||||
----------------
|
||||
To execute test scripts, you must build PHP with some SAPI, then you
|
||||
type "make test" to execute all or some test scripts saved under
|
||||
"tests" directory under source root directory.
|
||||
|
||||
Usage:
|
||||
make test
|
||||
|
||||
"make test" basically executes "run-tests.php" script
|
||||
under the source root (parallel builds will not work). Therefore you
|
||||
can execute the script as follows:
|
||||
|
||||
TEST_PHP_EXECUTABLE=sapi/cli/php \
|
||||
sapi/cli/php [-c /path/to/php.ini] run-tests.php [ext/foo/tests/GLOB]
|
||||
|
||||
|
||||
[Which "php" executable "make test" look for]
|
||||
---------------------------------------------
|
||||
You must use TEST_PHP_EXECUTABLE environment variable to explicitly
|
||||
select the php executable to be used to run the tests. That can either
|
||||
be the CLI or CGI executable.
|
||||
|
||||
"make test" executes "run-tests.php" script with "php" binary. Some
|
||||
test scripts such as session must be executed by CGI SAPI. Therefore,
|
||||
you must build PHP with CGI SAPI to perform all tests.
|
||||
|
||||
NOTE: PHP binary executing "run-tests.php" and php binary used for
|
||||
executing test scripts may differ. If you use different PHP binary for
|
||||
executing "run-tests.php" script, you may get errors.
|
||||
|
||||
|
||||
[Which php.ini is used]
|
||||
-----------------------
|
||||
"make test" uses the same php.ini file as it would once installed.
|
||||
The tests have been written to be independent of that php.ini file,
|
||||
so if you find a test that is affected by a setting, please report
|
||||
this, so we can address the issue.
|
||||
|
||||
|
||||
[Which test scripts are executed]
|
||||
---------------------------------
|
||||
"run-tests.php" ("make test"), without any arguments executes all
|
||||
test scripts by extracting all directories named "tests"
|
||||
from the source root and any subdirectories below. If there are files,
|
||||
which have a "phpt" extension, "run-tests.php" looks at the sections
|
||||
in these files, determines whether it should run it, by evaluating
|
||||
the 'SKIP' section. If the test is eligible for execution, the 'FILE'
|
||||
section is extracted into a ".php" file (with the same name besides
|
||||
the extension) and gets executed.
|
||||
When an argument is given or TESTS environment variable is set, the
|
||||
GLOB is expanded by the shell and any file with extension "*.phpt" is
|
||||
regarded as a test file.
|
||||
|
||||
Tester can easily execute tests selectively with as follows.
|
||||
|
||||
Examples:
|
||||
./sapi/cli/php run-tests.php ext/mbstring/*
|
||||
./sapi/cli/php run-tests.php ext/mbstring/020.phpt
|
||||
|
||||
|
||||
[Test results]
|
||||
--------------
|
||||
Test results are printed to standard output. If there is a failed test,
|
||||
the "run-tests.php" script saves the result, the expected result and the
|
||||
code executed to the test script directory. For example, if
|
||||
ext/myext/tests/myext.phpt fails to pass, the following files are created:
|
||||
|
||||
ext/myext/tests/myext.php - actual test file executed
|
||||
ext/myext/tests/myext.log - log of test execution (L)
|
||||
ext/myext/tests/myext.exp - expected output (E)
|
||||
ext/myext/tests/myext.out - output from test script (O)
|
||||
ext/myext/tests/myext.diff - diff of .out and .exp (D)
|
||||
|
||||
Failed tests are always bugs. Either the test is bugged or not considering
|
||||
factors applying to the tester's environment, or there is a bug in PHP.
|
||||
If this is a known bug, we strive to provide bug numbers, in either the
|
||||
test name or the file name. You can check the status of such a bug, by
|
||||
going to: http://bugs.php.net/12345 where 12345 is the bug number.
|
||||
For clarity and automated processing, bug numbers are prefixed by a hash
|
||||
sign '#' in test names and/or test cases are named bug12345.phpt.
|
||||
|
||||
NOTE: The files generated by tests can be selected by setting the
|
||||
environment variable TEST_PHP_LOG_FORMAT. For each file you want to be
|
||||
generated use the character in brackets as shown above (default is LEOD).
|
||||
The php file will be generated always.
|
||||
|
||||
NOTE: You can set environment variable TEST_PHP_DETAILED to enable
|
||||
detailed test information.
|
||||
|
||||
[Automated testing]
|
||||
If you like to keep up to speed, with latest developments and quality
|
||||
assurance, setting the environment variable NO_INTERACTION to 1, will not
|
||||
prompt the tester for any user input.
|
||||
|
||||
Normally, the exit status of "make test" is zero, regardless of the results
|
||||
of independent tests. Set the environment variable REPORT_EXIT_STATUS to 1,
|
||||
and "make test" will set the exit status ("$?") to non-zero, when an
|
||||
individual test has failed.
|
||||
|
||||
Example script to be run by cron(1):
|
||||
========== qa-test.sh =============
|
||||
#!/bin/sh
|
||||
|
||||
CO_DIR=$HOME/cvs/php4
|
||||
MYMAIL=qa-test@domain.com
|
||||
TMPDIR=/var/tmp
|
||||
TODAY=`date +"%Y%m%d"`
|
||||
|
||||
# Make sure compilation enviroment is correct
|
||||
CONFIGURE_OPTS='--disable-all --enable-cli --with-pcre'
|
||||
export MAKE=gmake
|
||||
export CC=gcc
|
||||
|
||||
# Set test environment
|
||||
export NO_INTERACTIVITY=1
|
||||
export REPORT_EXIT_STATUS=1
|
||||
|
||||
cd $CO_DIR
|
||||
cvs update . >>$TMPDIR/phpqatest.$TODAY
|
||||
./cvsclean ; ./buildconf ; ./configure $CONFIGURE_OPTS ; $MAKE
|
||||
$MAKE test >>$TMPDIR/phpqatest.$TODAY 2>&1
|
||||
if test $? -gt 0
|
||||
then
|
||||
cat $TMPDIR/phpqatest.$TODAY | mail -s"PHP-QA Test Failed for $TODAY" $MYMAIL
|
||||
fi
|
||||
========== end of qa-test.sh =============
|
||||
|
||||
NOTE: the exit status of run-tests.php will be 1 when
|
||||
REPORT_EXIT_STATUS is set. The result of "make test" may be higher
|
||||
than that. At present, gmake 3.79.1 returns 2, so it is
|
||||
advised to test for non-zero, rather then a specific value.
|
||||
|
||||
|
||||
[Creating new test files]
|
||||
-------------------------
|
||||
Writing test file is very easy if you are used to PHP.
|
||||
|
||||
Here is an actual test file from standard module.
|
||||
|
||||
===== ext/standard/tests/strings/strtr.phpt =======
|
||||
--TEST--
|
||||
strtr() function
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example. */
|
||||
$trans = array("hello"=>"hi", "hi"=>"hello", "a"=>"A", "world"=>"planet");
|
||||
var_dump(strtr("# hi all, I said hello world! #", $trans));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(32) "# hello All, I sAid hi planet! #"
|
||||
===== ext/standard/tests/strings/strtr.phpt =======
|
||||
|
||||
As you can see the file is devided into several sections. Below is a
|
||||
list of all possible sections:
|
||||
|
||||
"--TEST--" is title of the test (required).
|
||||
"--SKIPIF--" is condition when to skip this test (optional).
|
||||
"--POST--" is POST variable passed to test script (optional).
|
||||
"--GET--" is GET variable passed to test script (optional).
|
||||
"--INI--" each line contains an ini setting e.g. foo=bar (optional).
|
||||
"--FILE--" is the test script (required).
|
||||
"--EXPECT--" is the expected output from the test script (required).
|
||||
"--EXPECTF--" is an alternative of --EXPECT--. The difference is that
|
||||
this form uses sscanf for output validation (alternative).
|
||||
"--EXPECTREGEX--" is an alternative of --EXPECT--. This form allows the tester
|
||||
to specify the result in a regular expression (alternative).
|
||||
|
||||
A test must at least contain the sections TEST, FILE and either EXPECT
|
||||
or EXPECTF. When a test is called run-test.php takes the name from the
|
||||
TEST section and writes the FILE section into a ".php" file with the
|
||||
same name as the ".phpt" file. This ".php" file will then be executed
|
||||
and its output compared to the contents of the EXPECT section. It is a
|
||||
good idea to generate output with var_dump() calls.
|
||||
|
||||
/ext/standard/tests/strings/str_shuffle.phpt is a good example for using
|
||||
EXPECTF instead of EXPECT. From time to time the algorithm used for shuffle
|
||||
changed and sometimes the machine used to execute the code has influence
|
||||
on the result of shuffle. But it always returns a three character string
|
||||
detectable by %s. Other scan-able forms are %i for integers, %d for numbers
|
||||
only, %f for floating point values, %c for single characters and %x for
|
||||
hexadecimal values.
|
||||
|
||||
==== /ext/standard/tests/strings/str_shuffle.phpt ===
|
||||
--TEST--
|
||||
Testing str_shuffle.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example. */
|
||||
$s = '123';
|
||||
var_dump(str_shuffle($s));
|
||||
var_dump($s);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(3) %s
|
||||
string(3) "123"
|
||||
==== end of /ext/standard/tests/strings/str_shuffle.phpt ===
|
||||
|
||||
/ext/standard/tests/strings/strings001.phpt is a good example for using
|
||||
EXPECTREGEX instead of EXPECT. This test also shows that in EXPECTREGEX
|
||||
some characters need to be escaped since otherwise they would be
|
||||
interpreted as a regular expression.
|
||||
|
||||
==== /ext/standard/tests/strings/strings001.phpt ===
|
||||
--TEST--
|
||||
Test whether strstr() and strrchr() are binary safe.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example. */
|
||||
$s = "alabala nica".chr(0)."turska panica";
|
||||
var_dump(strstr($s, "nic"));
|
||||
var_dump(strrchr($s," nic"));
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
string\(18\) \"nica\x00turska panica\"
|
||||
string\(19\) \" nica\x00turska panica\"
|
||||
==== end of /ext/standard/tests/strings/strings001.phpt ===
|
||||
|
||||
Some tests depend on modules or functions available only in certain versions
|
||||
or they even require minimum version of php or zend. These tests should be
|
||||
skipped when the requirement cannot be fullfilled. To achieve this you can
|
||||
use the SKIPIF section. To tell run-test.php that your test should be skipped
|
||||
the SKIPIF section must print out the word "skip" followed by a reason why
|
||||
the test should skip.
|
||||
|
||||
==== /ext/exif/tests/exif005.phpt ===
|
||||
--TEST--
|
||||
Check for exif_read_data, unusual IFD start
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('exif')) print 'skip exif extension not available';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Do not change this test it is a REATME.TESTING example.
|
||||
* test5.jpg is a 1*1 image that contains an Exif section with ifd = 00000009h
|
||||
*/
|
||||
$image = exif_read_data('./ext/exif/tests/test5.jpg','',true,false);
|
||||
var_dump($image['IFD0']);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
["ImageDescription"]=>
|
||||
string(11) "Ifd00000009"
|
||||
["DateTime"]=>
|
||||
string(19) "2002:10:18 20:06:00"
|
||||
}
|
||||
==== end of /ext/exif/tests/exif005.phpt ===
|
||||
|
||||
Test script and SKIPIF code should be directly written into *.phpt. However,
|
||||
it is recommended to use include files when more test scripts depend on the
|
||||
same SKIPIF code or when certain test files need the same values for some
|
||||
input. But no file used by any test should have one of the following
|
||||
extensions: ".php", ".log", ".exp", ".out" or ".diff".
|
||||
|
||||
Tests should be named according to the following list:
|
||||
|
||||
Class: Name: Example:
|
||||
Tests for bugs bug<bugid>.phpt bug17123.phpt
|
||||
Tests for functions <functionname>.phpt dba_open.phpt
|
||||
General tests for extensions <extname><no>.phpt dba3.phpt
|
||||
|
||||
When you use an include file for the SKIPIF section it should be named
|
||||
"skipif.inc" and an include file used in the FILE section of many tests
|
||||
should be named "test.inc".
|
||||
|
||||
NOTE: All tests should run correctly with error_reporting(E_ALL) and
|
||||
display_errors=1. This is the default when called from run-test.php.
|
||||
If you have a good reason for lowering the error reporting, use --INI--
|
||||
section and comment this in your testcode.
|
||||
|
||||
NOTE: If your test intentionally generates a PHP warning message use
|
||||
$php_errormsg variable, which you can then output. This will result
|
||||
in a consistent error message output across all platforms and PHP
|
||||
configurations, preventing your test from failing due inconsistencies
|
||||
in the error message content.
|
||||
|
||||
[How to help us]
|
||||
----------------
|
||||
If you find bug in PHP, you can submit bug report AND test script
|
||||
for us. You don't have to write complete script, just give us test
|
||||
script with following format. Please test the script and make sure
|
||||
you write the correct ACTUAL OUTPUT and EXPECTED OUTPUT before you
|
||||
submit.
|
||||
|
||||
<?php
|
||||
/*
|
||||
Bug #12345
|
||||
substr() bug. Do not return expected string.
|
||||
|
||||
ACTUAL OUTPUT
|
||||
XYXA
|
||||
|
||||
EXPECTED OUTPUT
|
||||
ABCD
|
||||
*/
|
||||
|
||||
$str = "XYZABCD";
|
||||
echo substr($str,3,7);
|
||||
|
||||
?>
|
||||
@@ -1,123 +0,0 @@
|
||||
PHP Build System V5 Overview
|
||||
|
||||
- supports Makefile.ins during transition phase
|
||||
- not-really-portable Makefile includes have been eliminated
|
||||
- supports separate build directories without VPATH by using
|
||||
explicit rules only
|
||||
- does not waste disk-space/CPU-time for building temporary libraries
|
||||
=> especially noticeable on slower systems
|
||||
- slow recursive make replaced with one global Makefile
|
||||
- eases integration of proper dependencies
|
||||
- adds PHP_DEFINE(what[, value]) which creates a single include-file
|
||||
per what. This will allow more fine-grained dependencies.
|
||||
- abandoning the "one library per directory" concept
|
||||
- improved integration of the CLI
|
||||
- several new targets
|
||||
build-modules: builds and copies dynamic modules into modules/
|
||||
install-cli: installs the CLI only, so that the install-sapi
|
||||
target does only what its name says
|
||||
- finally abandoned automake (still requires aclocal at this time)
|
||||
- changed some configure-time constructs to run at buildconf-time
|
||||
- upgraded shtool to 1.5.4
|
||||
- removed $(moduledir) (use EXTENSION_DIR)
|
||||
|
||||
The Reason For a New System
|
||||
|
||||
It became more and more apparent that there is a severe need
|
||||
for addressing the portability concerns and improving the chance
|
||||
that your build is correct (how often have you been told to
|
||||
"make clean"? When this is done, you won't need to anymore).
|
||||
|
||||
|
||||
If You Build PHP on a Unix System
|
||||
|
||||
|
||||
You, as a user of PHP, will notice no changes. Of course, the build
|
||||
system will be faster, look better and work smarter.
|
||||
|
||||
|
||||
|
||||
If You Are Developing PHP
|
||||
|
||||
|
||||
|
||||
|
||||
Extension developers:
|
||||
|
||||
Makefile.ins are abandoned. The files which are to be compiled
|
||||
are specified in the config.m4 now using the following macro:
|
||||
|
||||
PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
|
||||
|
||||
E.g. this enables the extension foo which consists of three source-code
|
||||
modules, two in C and one in C++. And, depending on the user's wishes,
|
||||
the extension will even be built as a dynamic module.
|
||||
|
||||
The full syntax:
|
||||
|
||||
PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
|
||||
|
||||
Please have a look at acinclude.m4 for the gory details and meanings
|
||||
of the other parameters.
|
||||
|
||||
And that's basically it for the extension side.
|
||||
|
||||
If you previously built sub-libraries for this module, add
|
||||
the source-code files here as well. If you need to specify
|
||||
separate include directories, do it this way:
|
||||
|
||||
PHP_NEW_EXTENSION(foo, foo.c mylib/bar.c mylib/gregor.c,,,-I@ext_srcdir@/lib)
|
||||
|
||||
E.g. this builds the three files which are located relative to the
|
||||
extension source directory and compiles all three files with the
|
||||
special include directive (@ext_srcdir@ is automatically replaced).
|
||||
|
||||
Now, you need to tell the build system that you want to build files
|
||||
in a directory called $ext_builddir/lib:
|
||||
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/lib)
|
||||
|
||||
Make sure to call this after PHP_NEW_EXTENSION, because $ext_builddir
|
||||
is only set by the latter.
|
||||
|
||||
If you have a complex extension, you might to need add special
|
||||
Make rules. You can do this by calling PHP_ADD_MAKEFILE_FRAGMENT
|
||||
in your config.m4 after PHP_NEW_EXTENSION.
|
||||
|
||||
This will read a file in the source-dir of your extension called
|
||||
Makefile.frag. In this file, $(builddir) and $(srcdir) will be
|
||||
replaced by the values which are correct for your extension
|
||||
and which are again determined by the PHP_NEW_EXTENSION macro.
|
||||
|
||||
Make sure to prefix *all* relative paths correctly with either
|
||||
$(builddir) or $(srcdir). Because the build system does not
|
||||
change the working directory anymore, we must use either
|
||||
absolute paths or relative ones to the top build-directory.
|
||||
Correct prefixing ensures that.
|
||||
|
||||
|
||||
SAPI developers:
|
||||
|
||||
Instead of using PHP_SAPI=foo/PHP_BUILD_XYZ, you will need to type
|
||||
|
||||
PHP_SELECT_SAPI(name, type, sources.c)
|
||||
|
||||
I.e. specify the source-code files as above and also pass the
|
||||
information regarding how PHP is supposed to be built (shared
|
||||
module, program, etc).
|
||||
|
||||
For example for APXS:
|
||||
|
||||
PHP_SELECT_SAPI(apache, shared, sapi_apache.c mod_php4.c php_apache.c)
|
||||
|
||||
|
||||
|
||||
General info
|
||||
|
||||
The foundation for the new system is the flexible handling of
|
||||
sources and their contexts. With the help of macros you
|
||||
can define special flags for each source-file, where it is
|
||||
located, in which target context it can work, etc.
|
||||
|
||||
Have a look at the well documented macros
|
||||
PHP_ADD_SOURCES(_X) in acinclude.m4.
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
Advisory on the PHP Release Cycle
|
||||
|
||||
|
||||
Copyright & Liciencing
|
||||
|
||||
This Document is (c) Copyright 2000,2001 by The PHP Group
|
||||
|
||||
This Document is distributed 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.
|
||||
|
||||
|
||||
Table of Contents
|
||||
|
||||
1. Introduction
|
||||
2. Dealing with bugs
|
||||
2.1 As a QA Team Member
|
||||
2.2 As a Developer
|
||||
3. Releaseing another RC
|
||||
4. CVS During the Release Process
|
||||
4.1 Useful CVS Commands
|
||||
5 The Final Release
|
||||
6 Summary
|
||||
|
||||
|
||||
1. Introduction
|
||||
|
||||
This cycle should take place over roughly 10 days. When it is
|
||||
decided it is time for an Release to occur Andi/Zeev (Or
|
||||
Whoever) will tarball RC1, Tag & Branch CVS (see section 4)
|
||||
and then announce the RC on PHP-QA and PHP-DEV. At this
|
||||
point the build tracker and QA Bug System come into play.
|
||||
If you successfully build PHP then report it in the build
|
||||
tracker, If you then run and complete all the tests you
|
||||
should report this too in the build tracker when
|
||||
these features become avalible.
|
||||
|
||||
2. Dealing with Bugs
|
||||
|
||||
2.1 As a QA Team member
|
||||
|
||||
If you find a bug in an RC that you think is a showstopper
|
||||
then, even if it is a known bug, you should report it in the
|
||||
QA Bug system. This marks the bug for discussion at least,
|
||||
and preferably fixing before the actual release. This system
|
||||
is separate from the main bugs system so that important bugs
|
||||
dont get lost in the midst if lots of feature/change request
|
||||
in the approach to a release. It is imperitive where
|
||||
appropraite that as a QA'er a test script, Configure options
|
||||
and PHP.ini files are provided to enable the developer to
|
||||
reproduce the bug, this is an important part of our job. If
|
||||
you have a serious bug then you should also create a test
|
||||
script to be added to the tests dir of the php source so
|
||||
that at the end of the process to enable us to make sure bug
|
||||
does not return. It is not difficult to create these test
|
||||
scripts and a readme on it can be found in
|
||||
php4/tests/README.
|
||||
|
||||
|
||||
2.2 As a Developer
|
||||
|
||||
What should happen is that when a bug is reported it
|
||||
is send to php-dev and php-qa as with other bugs. We should
|
||||
have far stricter assignment system in this bug cycle rather
|
||||
than just leaving them. Once again bugs should be able to be
|
||||
marked as To Be Fixed Before release or moved to other bug
|
||||
system. (This is currently the Release Masters responsibility)
|
||||
|
||||
Then before the actual release the qa bugs system can be
|
||||
checked and if there are outstanding To Be Fixed Before
|
||||
release bugs the Developers can see this easyly rather than
|
||||
show stoppers being dismissed and not worried about.
|
||||
|
||||
When a bug is fixed the QAer who reported the bug is emailed
|
||||
and asked to test again and see if the bug is fixed.
|
||||
|
||||
3 Releasing another RC
|
||||
|
||||
If it is felt necessary that a 2nd RC is needed then it
|
||||
should be packaged as before and announced to both lists
|
||||
again. The testing process then starts again, the RC2 is
|
||||
added to the build tracker and QA'ers are asked to build and
|
||||
retest the scripts as appropriate, espectially if you
|
||||
reported a bug, you should test thourghly for your
|
||||
bug and make sure it no longer occurs. This will normally
|
||||
add anouther 3 days to the cycle, giving QA'ers time to
|
||||
build test and report back, then for developers to
|
||||
fix any problems.
|
||||
|
||||
4 CVS during the release process
|
||||
|
||||
At the point where the first RC is create a branch is
|
||||
formed. This branch is not altered form that point onward
|
||||
other than major bug fixes. Minor non important bug
|
||||
fixes should not be applied to this branch but to the main
|
||||
tree instead. Any major bug fixes should be applied to both
|
||||
trees. The developer should test and check the RC tree then
|
||||
also test and check the MAIN tree. This is their
|
||||
responsibility to make sure (as far as possible) that the
|
||||
bug fix works on both trees.
|
||||
|
||||
4.1 Useful CVS Commands
|
||||
|
||||
To create a Branch <Should only be done by person tarballing
|
||||
the RC (The Release Master)>:
|
||||
|
||||
$ cvs tag -b php_4_0_<Version>RC<NUMBER>
|
||||
IE:
|
||||
$ cvs tag -b php_4_0_1RC1
|
||||
|
||||
This should be executed in the PHP directory of an up to
|
||||
date checkout. Remember to also tag the Zend and TSRM repositories.
|
||||
|
||||
You can retrieve a branch in one of two ways: by checking it
|
||||
out fresh from the repository, or by switching an existing
|
||||
working copy over to the branch, I would suggest you
|
||||
checkout a new copy.
|
||||
|
||||
To check out a new copy:
|
||||
$ cvs checkout -r php_4_0_<Version>RC<NUMBER> php4
|
||||
IE:
|
||||
$ cvs checkout -r php_4_0_1RC1 php4
|
||||
|
||||
|
||||
To switch a working copy (Not recomended due to possible
|
||||
commiting to wrong branch)
|
||||
$ cvs update -r php_4_0_<Version>RC<NUMBER> php4
|
||||
IE:
|
||||
$ cvs update -r php_4_0_1RC1 php4
|
||||
|
||||
This should be done in the PHP4 directory itself.
|
||||
|
||||
To revert back to normal branch you should use the
|
||||
following:
|
||||
$ cvs update -A
|
||||
|
||||
To Commit to the branch you follow exactly the same
|
||||
procedure as normal
|
||||
$ cvs commit file.c
|
||||
|
||||
MAKE SURE YOU DO NOT COMMIT TO THE WRONG BRANCH.
|
||||
|
||||
5 The Final Release
|
||||
|
||||
When it is time to make the final release the following
|
||||
proceedure should be followed. The person who is tarballing
|
||||
the final release should check the QA bugs system and make
|
||||
sure there are no showstoppers left unfixed. If there are
|
||||
then bug the person the bug is assigned to until they fix
|
||||
it. If there are no more qa bugs then they should tag the
|
||||
branch as php_4_0_<Version> and tarball as usual. An email
|
||||
should be sent to PHP-GEN, PHP_DEV and PHP-QA about the new
|
||||
release and it should be added to php.net. The windows
|
||||
binaries and servelets should be built as soon as possible
|
||||
and added too, as should the windows installer.
|
||||
|
||||
6 Summary
|
||||
|
||||
Here is a summary of what a release cycle might look like:
|
||||
|
||||
Thurs: RC is agreed on and packaged, an email is sent to
|
||||
PHP_QA and PHP-DEV, the CVS is Branched and the
|
||||
Release Cycle Begins.
|
||||
|
||||
Mon: After a weekends testing most show stoppers should
|
||||
have been found (Hopefully) and the developers get to
|
||||
work on fixing them.
|
||||
|
||||
Thurs: A second RC is released if needed with the new bug
|
||||
fixes in and the QAers test again.
|
||||
|
||||
Sun: A review is made of all outstanding bugs and any show
|
||||
stoppers should be fixed. if there are no show
|
||||
stoppers then the final release is packaged and
|
||||
released on the monday morning on php.net
|
||||
|
||||
Mon: Release is made.
|
||||
|
||||
|
||||
James
|
||||
--
|
||||
James Moore
|
||||
PHP QA Team
|
||||
jmoore@php.net
|
||||
|
||||
@@ -22,6 +22,8 @@ Zend
|
||||
* Const'ify APIs. Right now, many functions leave parameters untouched,
|
||||
but don't declare those as const. This makes interaction with other
|
||||
interfaces difficult which pass const parameters to us.
|
||||
* Add try..catch/throw exception handling.
|
||||
* Fix Zend shallow copy issues with objects and arrays.
|
||||
|
||||
|
||||
global
|
||||
@@ -41,8 +43,16 @@ global
|
||||
* on some platforms unimplemented function will just do nothing
|
||||
(e.g. symlink) they should print a warning or not even be defined!
|
||||
(DONE ?)
|
||||
* Finish PHP streams abstraction, nuke all that issock stuff, implement SSL
|
||||
socket support. (wez)
|
||||
- ext/ftp/ -> all FILEs to streams
|
||||
- ext/bz2/ -> convert to stream impl.
|
||||
* Use arg_separator.input to implode args in the CGI sapi extension
|
||||
and arg_separator.input to explode in php_build_argv(). (DONE?)
|
||||
* Change the odbc_fetch_into() function to require ALWAYS the first two
|
||||
parameters ($conn_id and $array), and make the third (row) be optional.
|
||||
* Remove --with-openlink configure option (--with-iodbc replaces it).
|
||||
* Implement flush feature suitable for nested output buffers.
|
||||
|
||||
For PHP 5.0.0
|
||||
* bundle and use curl lib for fopen wrapper.
|
||||
@@ -66,7 +76,6 @@ global
|
||||
* 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.
|
||||
* Implement flush feature suitable for nested output buffers.
|
||||
|
||||
|
||||
documentation
|
||||
@@ -78,16 +87,10 @@ documentation
|
||||
* Add developer documentation.
|
||||
* Add detailed documentation for Java extension.
|
||||
|
||||
ext/bz2
|
||||
-------
|
||||
* Add an ini directive to specify the size of decompression buffer.
|
||||
The default 4k is too small for large files and also requires much time
|
||||
for decompression. 40k is suitable for such files, however it may be too
|
||||
much under certain environments. There should be appropriate default
|
||||
settings for the various SAPI modules (e.g. apache and cli).
|
||||
|
||||
ext/curl
|
||||
--------
|
||||
* Use the cURL write handler to save data for use when returning data or
|
||||
outputting data.
|
||||
* Have a warning scheme for when people use unsupported features.
|
||||
|
||||
ext/oci8
|
||||
@@ -98,26 +101,10 @@ ext/oci8
|
||||
* Make allow_call_time_pass_reference=Off working.
|
||||
* For additional todo information, see oci8.c, in ext/oci8
|
||||
|
||||
ext/odbc
|
||||
--------
|
||||
For PHP 4.3.0:
|
||||
* update all php_error calls to php_error_docref where valid
|
||||
* integrate EXPERIMENTAL ODBC update for use in PHP 5.0, use for
|
||||
testing purposes only.
|
||||
|
||||
For PHP 5.0.0
|
||||
* Activate EXPERIMENTAL ODBC codebase update
|
||||
|
||||
ext/pcre
|
||||
--------
|
||||
* Allow user to set PCRE_NOTEMPTY, PCRE_ANCHORED at execution time, maybe
|
||||
|
||||
ext/pcntl
|
||||
---------
|
||||
* Change internal callback handler to use TICKS
|
||||
* Remove all zend_extension code
|
||||
* Add object callback support to pcntl_signal()
|
||||
|
||||
ext/pgsql
|
||||
---------
|
||||
For PHP 4.3.0:
|
||||
@@ -142,8 +129,8 @@ ext/session
|
||||
|
||||
ext/sockets
|
||||
-----------
|
||||
* Implement IPv6
|
||||
* Review/Fix vectors
|
||||
* Make the extension work on windows (Daniel Beulshausen)
|
||||
* Make the extension work with Solaris and the Sun GCC
|
||||
|
||||
ext/standard
|
||||
------------
|
||||
@@ -158,6 +145,14 @@ ext/standard
|
||||
basename()
|
||||
dirname()
|
||||
strrpos()
|
||||
strrchr()
|
||||
strip_tags()
|
||||
* Rewrite win32 SMTP code to be usable for *ix to, maybe as a (default)
|
||||
module of its own (Hartmut)
|
||||
|
||||
ext/zziplib
|
||||
------------
|
||||
* More fully support the zziplib API
|
||||
|
||||
ext/wddx
|
||||
--------
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
- clean up .cvsignores
|
||||
- purge Makefile.ins and replace PHP_EXTENSION in config.m4s
|
||||
with appropiate calls to PHP_NEW_EXTENSION
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
This is an overview over existing segfaults in the current PHP source
|
||||
tree.
|
||||
|
||||
|
||||
Fixed:
|
||||
|
||||
mb_convert_encoding (Moriyoshi)
|
||||
socket_iovec_alloc (Rasmus)
|
||||
exif_imagetype,exif_thumbnail (Rasmus)
|
||||
dbase_open (Rasmus)
|
||||
array_pad (Rasmus)
|
||||
setlocale (Rasmus)
|
||||
unregister_tick_function (Rasmus)
|
||||
bcsub (Rasmus)
|
||||
str_repeat (Ilia)
|
||||
imagecopyresized (Ilia)
|
||||
mhash_keygen_s2k (Ilia)
|
||||
bundled gd (Ilia)
|
||||
mb_ereg, mb_ereg_match, mb_eregi, mb_split (Moriyoshi)
|
||||
xml_parser_create (Moriyoshi)
|
||||
ob_start (Sascha)
|
||||
imagecreate/-truecolor (Sascha)
|
||||
flock (Sascha)
|
||||
register_shutdown_function (Sascha)
|
||||
mb_strcut('', [number greater than the length of first arg]) (Moriyoshi)
|
||||
ext/exif, ext/dba (Marcus)
|
||||
php_base64_encode (Moriyoshi)
|
||||
|
||||
Open:
|
||||
|
||||
the dbase extension (1)
|
||||
socket_select (2)
|
||||
pack (3)
|
||||
|
||||
(1) heap corruption, mostly visible in malloc-related calls. Whether you see
|
||||
this or not might depend on your libc/compiler. Hard to track down,
|
||||
because the result of the corruption might be quite delayed.
|
||||
|
||||
Reproducable with glibc-2.3/gcc 3.2.2 by:
|
||||
|
||||
cat <<X | php do_crash
|
||||
dbase_add_record
|
||||
dbase_close
|
||||
dbase_create
|
||||
dbase_delete_record
|
||||
dbase_get_record
|
||||
dbase_get_record_with_names
|
||||
dbase_numfields
|
||||
dbase_numrecords
|
||||
dbase_open
|
||||
X
|
||||
|
||||
(2) heap corruption, dies in efree()/execute()
|
||||
|
||||
Methodology
|
||||
|
||||
1. Use a plain PHP_4_3 tree
|
||||
2. Use the config.nice from ammendment 1.
|
||||
3. Download the test script from:
|
||||
|
||||
<URL:http://schumann.cx/do_crash.txt>
|
||||
|
||||
4a. Use the scripts funcparse.awk/genfunclist.sh from phpdoc/scripts
|
||||
for creating a plain text function list. Feed that list to
|
||||
the script. Avoid calls like pcntl_fork. Manually remove functions
|
||||
which take too long to finish/eat up all memory.
|
||||
|
||||
4b. For testing a single function, echo the name of the function to
|
||||
the script like this:
|
||||
|
||||
echo dbase_open | php do_crash.txt
|
||||
|
||||
(3) multiple integer overflows, ex. pack("d4294967297", 2);
|
||||
|
||||
Amendment 1.
|
||||
|
||||
CFLAGS='-O0 -g' \
|
||||
'../src/php4/configure' \
|
||||
'--enable-pcntl' \
|
||||
'--enable-shmop' \
|
||||
'--enable-sysvsem' \
|
||||
'--enable-sysvshm' \
|
||||
'--enable-wddx' \
|
||||
'--enable-yp' \
|
||||
'--enable-filepro' \
|
||||
'--enable-ftp' \
|
||||
'--enable-dba' \
|
||||
'--enable-dbase' \
|
||||
'--enable-dio' \
|
||||
'--enable-exif' \
|
||||
'--enable-mbstring' \
|
||||
'--enable-mbregex' \
|
||||
'--enable-sockets' \
|
||||
'--enable-bcmath' \
|
||||
'--enable-calendar' \
|
||||
'--enable-pcntl' \
|
||||
'--enable-shmop' \
|
||||
'--enable-sysvsem' \
|
||||
'--enable-sysvshm' \
|
||||
'--enable-wddx' \
|
||||
'--enable-yp' \
|
||||
'--enable-filepro' \
|
||||
'--enable-ftp' \
|
||||
'--enable-dba' \
|
||||
'--enable-dbase' \
|
||||
'--enable-dio' \
|
||||
'--enable-exif' \
|
||||
'--enable-mbstring' \
|
||||
'--enable-mbregex' \
|
||||
'--enable-sockets' \
|
||||
'--enable-bcmath' \
|
||||
'--enable-calendar' \
|
||||
"$@"
|
||||
|
||||
+10
-49
@@ -15,6 +15,7 @@
|
||||
#ifdef ZTS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
@@ -79,7 +80,7 @@ static FILE *tsrm_error_file;
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define TSRM_ERROR(args)
|
||||
#define TSRM_ERROR
|
||||
#define TSRM_SAFE_RETURN_RSRC(array, offset, range) \
|
||||
if (offset==0) { \
|
||||
return &array; \
|
||||
@@ -95,10 +96,9 @@ static pthread_key_t tls_key;
|
||||
static int tls_key;
|
||||
#elif defined(TSRM_WIN32)
|
||||
static DWORD tls_key;
|
||||
#elif defined(BETHREADS)
|
||||
static int32 tls_key;
|
||||
#endif
|
||||
|
||||
|
||||
/* Startup TSRM (call once for the entire process) */
|
||||
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
|
||||
{
|
||||
@@ -111,8 +111,6 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
|
||||
st_key_create(&tls_key, 0);
|
||||
#elif defined(TSRM_WIN32)
|
||||
tls_key = TlsAlloc();
|
||||
#elif defined(BETHREADS)
|
||||
tls_key = tls_allocate();
|
||||
#endif
|
||||
|
||||
tsrm_error_file = stderr;
|
||||
@@ -181,7 +179,6 @@ TSRM_API void tsrm_shutdown(void)
|
||||
#if defined(GNUPTH)
|
||||
pth_kill();
|
||||
#elif defined(PTHREADS)
|
||||
pthread_setspecific(tls_key, 0);
|
||||
pthread_key_delete(tls_key);
|
||||
#elif defined(TSRM_WIN32)
|
||||
TlsFree(tls_key);
|
||||
@@ -262,8 +259,6 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
|
||||
st_thread_setspecific(tls_key, (void *) *thread_resources_ptr);
|
||||
#elif defined(TSRM_WIN32)
|
||||
TlsSetValue(tls_key, (void *) *thread_resources_ptr);
|
||||
#elif defined(BETHREADS)
|
||||
tls_set(tls_key, (void*) *thread_resources_ptr);
|
||||
#endif
|
||||
|
||||
if (tsrm_new_thread_begin_handler) {
|
||||
@@ -303,8 +298,6 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
|
||||
thread_resources = st_thread_getspecific(tls_key);
|
||||
#elif defined(TSRM_WIN32)
|
||||
thread_resources = TlsGetValue(tls_key);
|
||||
#elif defined(BETHREADS)
|
||||
thread_resources = (tsrm_tls_entry*)tls_get(tls_key);
|
||||
#else
|
||||
thread_resources = NULL;
|
||||
#endif
|
||||
@@ -419,8 +412,6 @@ TSRM_API THREAD_T tsrm_thread_id(void)
|
||||
{
|
||||
#ifdef TSRM_WIN32
|
||||
return GetCurrentThreadId();
|
||||
#elif defined(NETWARE)
|
||||
return NXThreadGetId();
|
||||
#elif defined(GNUPTH)
|
||||
return pth_self();
|
||||
#elif defined(PTHREADS)
|
||||
@@ -431,8 +422,6 @@ TSRM_API THREAD_T tsrm_thread_id(void)
|
||||
return PIThread_getCurrent();
|
||||
#elif defined(TSRM_ST)
|
||||
return st_thread_self();
|
||||
#elif defined(BETHREADS)
|
||||
return find_thread(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -440,18 +429,11 @@ TSRM_API THREAD_T tsrm_thread_id(void)
|
||||
/* Allocate a mutex */
|
||||
TSRM_API MUTEX_T tsrm_mutex_alloc(void)
|
||||
{
|
||||
MUTEX_T mutexp;
|
||||
#ifdef NETWARE
|
||||
long flags = 0; /* Don't require NX_MUTEX_RECURSIVE, I guess */
|
||||
NXHierarchy_t order = 0;
|
||||
NX_LOCK_INFO_ALLOC (lockInfo, "PHP-TSRM", 0);
|
||||
#endif
|
||||
MUTEX_T mutexp;
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
mutexp = malloc(sizeof(CRITICAL_SECTION));
|
||||
mutexp = malloc(sizeof(CRITICAL_SECTION));
|
||||
InitializeCriticalSection(mutexp);
|
||||
#elif defined(NETWARE)
|
||||
mutexp = NXMutexAlloc(flags, order, &lockInfo); /* return value ignored for now */
|
||||
#elif defined(GNUPTH)
|
||||
mutexp = (MUTEX_T) malloc(sizeof(*mutexp));
|
||||
pth_mutex_init(mutexp);
|
||||
@@ -464,26 +446,20 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void)
|
||||
mutexp = PIPlatform_allocLocalMutex();
|
||||
#elif defined(TSRM_ST)
|
||||
mutexp = st_mutex_new();
|
||||
#elif defined(BETHREADS)
|
||||
mutexp = (beos_ben*)malloc(sizeof(beos_ben));
|
||||
mutexp->ben = 0;
|
||||
mutexp->sem = create_sem(1, "PHP sempahore");
|
||||
#endif
|
||||
#ifdef THR_DEBUG
|
||||
printf("Mutex created thread: %d\n",mythreadid());
|
||||
printf("Mutex created thread: %d\n",mythreadid());
|
||||
#endif
|
||||
return( mutexp );
|
||||
return( mutexp );
|
||||
}
|
||||
|
||||
|
||||
/* Free a mutex */
|
||||
TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
|
||||
{
|
||||
if (mutexp) {
|
||||
if (mutexp) {
|
||||
#ifdef TSRM_WIN32
|
||||
DeleteCriticalSection(mutexp);
|
||||
#elif defined(NETWARE)
|
||||
NXMutexFree(mutexp);
|
||||
#elif defined(GNUPTH)
|
||||
free(mutexp);
|
||||
#elif defined(PTHREADS)
|
||||
@@ -495,13 +471,10 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
|
||||
PISync_delete(mutexp);
|
||||
#elif defined(TSRM_ST)
|
||||
st_mutex_destroy(mutexp);
|
||||
#elif defined(BETHREADS)
|
||||
delete_sem(mutexp->sem);
|
||||
free(mutexp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef THR_DEBUG
|
||||
printf("Mutex freed thread: %d\n",mythreadid());
|
||||
printf("Mutex freed thread: %d\n",mythreadid());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -513,8 +486,6 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
|
||||
#ifdef TSRM_WIN32
|
||||
EnterCriticalSection(mutexp);
|
||||
return 1;
|
||||
#elif defined(NETWARE)
|
||||
return NXLock(mutexp);
|
||||
#elif defined(GNUPTH)
|
||||
return pth_mutex_acquire(mutexp, 0, NULL);
|
||||
#elif defined(PTHREADS)
|
||||
@@ -525,10 +496,6 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
|
||||
return PISync_lock(mutexp);
|
||||
#elif defined(TSRM_ST)
|
||||
return st_mutex_lock(mutexp);
|
||||
#elif defined(BETHREADS)
|
||||
if (atomic_add(&mutexp->ben, 1) != 0)
|
||||
return acquire_sem(mutexp->sem);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -540,8 +507,6 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
|
||||
#ifdef TSRM_WIN32
|
||||
LeaveCriticalSection(mutexp);
|
||||
return 1;
|
||||
#elif defined(NETWARE)
|
||||
return NXUnlock(mutexp);
|
||||
#elif defined(GNUPTH)
|
||||
return pth_mutex_release(mutexp);
|
||||
#elif defined(PTHREADS)
|
||||
@@ -552,10 +517,6 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
|
||||
return PISync_unlock(mutexp);
|
||||
#elif defined(TSRM_ST)
|
||||
return st_mutex_unlock(mutexp);
|
||||
#elif defined(BETHREADS)
|
||||
if (atomic_add(&mutexp->ben, -1) != 1)
|
||||
return release_sem(mutexp->sem);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+1
-19
@@ -13,14 +13,12 @@
|
||||
#ifndef TSRM_H
|
||||
#define TSRM_H
|
||||
|
||||
/* #ifndef WIN32 */
|
||||
#if !defined(WIN32) && !defined(NETWARE)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "tsrm_config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# define TSRM_WIN32
|
||||
# include "tsrm_config.w32.h"
|
||||
#endif
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
@@ -38,18 +36,12 @@
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
# include <windows.h>
|
||||
#elif defined(NETWARE)
|
||||
# include <nks/thread.h>
|
||||
# include <nks/synch.h>
|
||||
#elif defined(GNUPTH)
|
||||
# include <pth.h>
|
||||
#elif defined(PTHREADS)
|
||||
# include <pthread.h>
|
||||
#elif defined(TSRM_ST)
|
||||
# include <st.h>
|
||||
#elif defined(BETHREADS)
|
||||
#include <kernel/OS.h>
|
||||
#include <TLS.h>
|
||||
#endif
|
||||
|
||||
typedef int ts_rsrc_id;
|
||||
@@ -58,9 +50,6 @@ typedef int ts_rsrc_id;
|
||||
#ifdef TSRM_WIN32
|
||||
# define THREAD_T DWORD
|
||||
# define MUTEX_T CRITICAL_SECTION *
|
||||
#elif defined(NETWARE)
|
||||
# define THREAD_T NXThreadId_t
|
||||
# define MUTEX_T NXMutex_t *
|
||||
#elif defined(GNUPTH)
|
||||
# define THREAD_T pth_t
|
||||
# define MUTEX_T pth_mutex_t *
|
||||
@@ -76,13 +65,6 @@ typedef int ts_rsrc_id;
|
||||
#elif defined(TSRM_ST)
|
||||
# define THREAD_T st_thread_t
|
||||
# define MUTEX_T st_mutex_t
|
||||
#elif defined(BETHREADS)
|
||||
# define THREAD_T thread_id
|
||||
typedef struct {
|
||||
sem_id sem;
|
||||
int32 ben;
|
||||
} beos_ben;
|
||||
# define MUTEX_T beos_ben *
|
||||
#endif
|
||||
|
||||
typedef void (*ts_allocate_ctor)(void *, void ***);
|
||||
|
||||
+19
-24
@@ -102,31 +102,26 @@ dnl -threads gcc (HP-UX)
|
||||
dnl
|
||||
AC_DEFUN(PTHREADS_CHECK,[
|
||||
|
||||
if test "$beos_threads" = "1"; then
|
||||
pthreads_working="yes"
|
||||
ac_cv_pthreads_cflags=""
|
||||
else
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LIBS=$LIBS
|
||||
PTHREADS_ASSIGN_VARS
|
||||
PTHREADS_CHECK_COMPILE
|
||||
LIBS=$save_LIBS
|
||||
CFLAGS=$save_CFLAGS
|
||||
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 -kthread -pthread -pthreads -mthreads -Kthread -threads -mt -qthreaded; 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_cflags,ac_cv_pthreads_cflags,[
|
||||
ac_cv_pthreads_cflags=
|
||||
if test "$pthreads_working" != "yes"; then
|
||||
for flag in -kthread -pthread -pthreads -mthreads -Kthread -threads -mt -qthreaded; 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
|
||||
])
|
||||
|
||||
|
||||
+8
-12
@@ -73,19 +73,15 @@ sinclude(TSRM/threads.m4)
|
||||
AC_DEFUN(TSRM_CHECK_PTHREADS,[
|
||||
|
||||
PTHREADS_CHECK
|
||||
|
||||
if test "$beos_threads" = "1"; then
|
||||
AC_DEFINE(BETHREADS, 1, Whether to use native BeOS threads)
|
||||
else
|
||||
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)
|
||||
|
||||
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)
|
||||
])
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef TSRM_CONFIG_NW_H
|
||||
#define TSRM_CONFIG_NW_H
|
||||
|
||||
#define HAVE_UTIME 1
|
||||
|
||||
/* Though we have alloca(), this seems to be causing some problem with the stack pointer -- hence not using it */
|
||||
/* #define HAVE_ALLOCA 1 */
|
||||
|
||||
#endif
|
||||
@@ -4,10 +4,6 @@
|
||||
#define HAVE_UTIME 1
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
#undef inline
|
||||
#ifdef ZEND_WIN32_FORCE_INLINE
|
||||
# define inline __forceinline
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
# define TSRM_WIN32
|
||||
#endif
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
# include "tsrm_config.w32.h"
|
||||
#elif defined(NETWARE)
|
||||
# include "tsrm_config.nw.h"
|
||||
#else
|
||||
#ifndef TSRM_WIN32
|
||||
# include "tsrm_config.h"
|
||||
# include <sys/param.h>
|
||||
#else
|
||||
# include "tsrm_config.w32.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
#ifdef TSRM_WIN32
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#ifndef __GNUC__
|
||||
# ifndef HAVE_ALLOCA_H
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
#pragma alloca
|
||||
# else
|
||||
|
||||
-260
@@ -1,260 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 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: Venkat Raghavan S <rvenkat@novell.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "TSRM.h"
|
||||
|
||||
#ifdef NETWARE
|
||||
|
||||
#ifdef USE_MKFIFO
|
||||
#include <sys/stat.h>
|
||||
#elif !defined(USE_PIPE_OPEN) /* NXFifoOpen */
|
||||
#include <nks/fsio.h>
|
||||
#endif
|
||||
|
||||
#include <nks/vm.h>
|
||||
#include <nks/memory.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mktemp.h"
|
||||
|
||||
/* strtok() call in LibC is abending when used in a different address space -- hence using
|
||||
PHP's version itself for now : Venkat (30/4/02) */
|
||||
#include "tsrm_strtok_r.h"
|
||||
#define tsrm_strtok_r(a,b,c) strtok((a),(b))
|
||||
|
||||
#define WHITESPACE " \t"
|
||||
#define MAX_ARGS 10
|
||||
|
||||
|
||||
TSRM_API FILE* popen(const char *commandline, const char *type)
|
||||
{
|
||||
char *command = NULL, *argv[MAX_ARGS] = {'\0'}, **env = NULL;
|
||||
char *tempName = "sys:/php/temp/phpXXXXXX.tmp";
|
||||
char *filePath = NULL;
|
||||
char *ptr = NULL;
|
||||
int ptrLen = 0, argc = 0, i = 0, envCount = 0, err = 0;
|
||||
FILE *stream = NULL;
|
||||
#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
|
||||
int pipe_handle;
|
||||
int mode = O_RDONLY;
|
||||
#else
|
||||
NXHandle_t pipe_handle;
|
||||
NXMode_t mode = NX_O_RDONLY;
|
||||
#endif
|
||||
NXExecEnvSpec_t envSpec;
|
||||
NXNameSpec_t nameSpec;
|
||||
NXVmId_t newVM = 0;
|
||||
|
||||
/* Check for validity of input parameters */
|
||||
if (!commandline || !type)
|
||||
return NULL;
|
||||
|
||||
/* Get temporary file name */
|
||||
filePath = mktemp(tempName);
|
||||
/*consoleprintf ("PHP | popen: file path = %s, mode = %s\n", filePath, type);*/
|
||||
if (!filePath)
|
||||
return NULL;
|
||||
|
||||
/* Set pipe mode according to type -- for now allow only "r" or "w" */
|
||||
if (strcmp(type, "r") == 0)
|
||||
#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
|
||||
mode = O_RDONLY;
|
||||
#else
|
||||
mode = NX_O_RDONLY;
|
||||
#endif
|
||||
else if (strcmp(type, "w") == 0)
|
||||
#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
|
||||
mode = O_WRONLY;
|
||||
#else
|
||||
mode = NX_O_WRONLY;
|
||||
#endif
|
||||
else
|
||||
return NULL;
|
||||
|
||||
#ifdef USE_PIPE_OPEN
|
||||
pipe_handle = pipe_open(filePath, mode);
|
||||
/*consoleprintf ("PHP | popen: pipe_open() returned %d\n", pipe_handle);*/
|
||||
if (pipe_handle == -1)
|
||||
return NULL;
|
||||
#elif defined(USE_MKFIFO)
|
||||
pipe_handle = mkfifo(filePath, mode);
|
||||
consoleprintf ("PHP | popen: mkfifo() returned %d\n", pipe_handle);
|
||||
if (pipe_handle == -1)
|
||||
return NULL;
|
||||
#else
|
||||
/*
|
||||
- NetWare doesn't require first parameter
|
||||
- Allowing LibC to choose the buffer size for now
|
||||
*/
|
||||
err = NXFifoOpen(0, filePath, mode, 0, &pipe_handle);
|
||||
/*consoleprintf ("PHP | popen: NXFifoOpen() returned %d\n", err);*/
|
||||
if (err)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
/* Copy the environment variables in preparation for the spawn call */
|
||||
|
||||
envCount = NXGetEnvCount() + 1; /* add one for NULL */
|
||||
env = (char**)NXMemAlloc(sizeof(char*) * envCount, 0);
|
||||
if (!env)
|
||||
return NULL;
|
||||
|
||||
err = NXCopyEnv(env, envCount);
|
||||
consoleprintf ("PHP | popen: NXCopyEnv() returned %d\n", err);
|
||||
if (err)
|
||||
{
|
||||
NXMemFree (env);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Separate commandline string into words */
|
||||
consoleprintf ("PHP | popen: commandline = %s\n", commandline);
|
||||
ptr = tsrm_strtok_r((char*)commandline, WHITESPACE, NULL);
|
||||
ptrLen = strlen(ptr);
|
||||
|
||||
command = (char*)malloc(ptrLen + 1);
|
||||
if (!command)
|
||||
{
|
||||
NXMemFree (env);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy (command, ptr);
|
||||
|
||||
ptr = tsrm_strtok_r(NULL, WHITESPACE, NULL);
|
||||
while (ptr && (argc < MAX_ARGS))
|
||||
{
|
||||
ptrLen = strlen(ptr);
|
||||
|
||||
argv[argc] = (char*)malloc(ptrLen + 1);
|
||||
if (!argv[argc])
|
||||
{
|
||||
NXMemFree (env);
|
||||
|
||||
if (command)
|
||||
free (command);
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (argv[i])
|
||||
free (argv[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy (argv[argc], ptr);
|
||||
|
||||
argc++;
|
||||
|
||||
ptr = tsrm_strtok_r(NULL, WHITESPACE, NULL);
|
||||
}
|
||||
consoleprintf ("PHP | popen: commandline string parsed into tokens\n");
|
||||
/* Setup the execution environment and spawn new process */
|
||||
|
||||
envSpec.esFlags = 0; /* Not used */
|
||||
envSpec.esArgc = argc;
|
||||
envSpec.esArgv = (void**)argv;
|
||||
envSpec.esEnv = (void**)env;
|
||||
|
||||
envSpec.esStdin.ssType =
|
||||
envSpec.esStdout.ssType = NX_OBJ_FIFO;
|
||||
envSpec.esStderr.ssType = NX_OBJ_FILE;
|
||||
/*
|
||||
envSpec.esStdin.ssHandle =
|
||||
envSpec.esStdout.ssHandle =
|
||||
envSpec.esStderr.ssHandle = -1;
|
||||
*/
|
||||
envSpec.esStdin.ssPathCtx =
|
||||
envSpec.esStdout.ssPathCtx =
|
||||
envSpec.esStderr.ssPathCtx = NULL;
|
||||
|
||||
#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
|
||||
if (mode == O_RDONLY)
|
||||
#else
|
||||
if (mode == NX_O_RDONLY)
|
||||
#endif
|
||||
{
|
||||
envSpec.esStdin.ssPath = filePath;
|
||||
envSpec.esStdout.ssPath = stdout;
|
||||
}
|
||||
else /* Write Only */
|
||||
{
|
||||
envSpec.esStdin.ssPath = stdin;
|
||||
envSpec.esStdout.ssPath = filePath;
|
||||
}
|
||||
|
||||
envSpec.esStderr.ssPath = stdout;
|
||||
|
||||
nameSpec.ssType = NX_OBJ_FIFO;
|
||||
/* nameSpec.ssHandle = 0; */ /* Not used */
|
||||
nameSpec.ssPathCtx = NULL; /* Not used */
|
||||
nameSpec.ssPath = argv[0];
|
||||
consoleprintf ("PHP | popen: environment setup\n");
|
||||
err = NXVmSpawn(&nameSpec, &envSpec, 0, &newVM);
|
||||
consoleprintf ("PHP | popen: NXVmSpawn() returned %d\n", err);
|
||||
if (!err)
|
||||
/* Get file pointer corresponding to the pipe (file) opened */
|
||||
stream = fdopen(pipe_handle, type);
|
||||
|
||||
/* Clean-up */
|
||||
|
||||
if (env)
|
||||
NXMemFree (env);
|
||||
|
||||
if (pipe_handle)
|
||||
#if defined(USE_PIPE_OPEN) || defined(USE_MKFIFO)
|
||||
close(pipe_handle);
|
||||
#else
|
||||
NXClose(pipe_handle);
|
||||
#endif
|
||||
|
||||
if (command)
|
||||
free (command);
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (argv[i])
|
||||
free (argv[i]);
|
||||
}
|
||||
consoleprintf ("PHP | popen: all clean-up done, returning...\n");
|
||||
return stream;
|
||||
}
|
||||
|
||||
TSRM_API int pclose(FILE* stream)
|
||||
{
|
||||
int err = 0;
|
||||
NXHandle_t fd = 0;
|
||||
|
||||
/* Get the process associated with this pipe (file) handle and terminate it */
|
||||
fd = fileno(stream);
|
||||
NXClose (fd);
|
||||
|
||||
err = fclose(stream);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
+108
-193
@@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -36,21 +36,12 @@
|
||||
#include "tsrm_win32.h"
|
||||
#endif
|
||||
|
||||
#ifdef NETWARE
|
||||
/*#include "pipe.h"*/
|
||||
#include "tsrm_nw.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_REALPATH
|
||||
#define realpath(x,y) strcpy(y,x)
|
||||
#endif
|
||||
|
||||
#define VIRTUAL_CWD_DEBUG 0
|
||||
|
||||
#include "TSRM.h"
|
||||
|
||||
/* Only need mutex for popen() in Windows and NetWare, because it doesn't chdir() on UNIX */
|
||||
#if (defined(TSRM_WIN32) || defined(NETWARE)) && defined(ZTS)
|
||||
/* Only need mutex for popen() in Windows because it doesn't chdir() on UNIX */
|
||||
#if defined(TSRM_WIN32) && defined(ZTS)
|
||||
MUTEX_T cwd_mutex;
|
||||
#endif
|
||||
|
||||
@@ -92,15 +83,8 @@ static int php_check_dots(const char *element, int n)
|
||||
(len >= 2 && !php_check_dots(element, len))
|
||||
|
||||
#define IS_DIRECTORY_CURRENT(element, len) \
|
||||
(len == 1 && element[0] == '.')
|
||||
(len == 1 && ptr[0] == '.')
|
||||
|
||||
#elif defined(NETWARE)
|
||||
/* NetWare has strtok() (in LibC) and allows both slashes in paths, like Windows --
|
||||
but rest of the stuff is like Unix */
|
||||
/* strtok() call in LibC is abending when used in a different address space -- hence using
|
||||
PHP's version itself for now */
|
||||
/*#define tsrm_strtok_r(a,b,c) strtok((a),(b))*/
|
||||
#define TOKENIZER_STRING "/\\"
|
||||
|
||||
#else
|
||||
#define TOKENIZER_STRING "/"
|
||||
@@ -111,12 +95,12 @@ static int php_check_dots(const char *element, int n)
|
||||
|
||||
#ifndef IS_DIRECTORY_UP
|
||||
#define IS_DIRECTORY_UP(element, len) \
|
||||
(len == 2 && element[0] == '.' && element[1] == '.')
|
||||
(len == 2 && memcmp(element, "..", 2) == 0)
|
||||
#endif
|
||||
|
||||
#ifndef IS_DIRECTORY_CURRENT
|
||||
#define IS_DIRECTORY_CURRENT(element, len) \
|
||||
(len == 1 && element[0] == '.')
|
||||
(len == 1 && ptr[0] == '.')
|
||||
#endif
|
||||
|
||||
/* define this to check semantics */
|
||||
@@ -137,15 +121,9 @@ static int php_check_dots(const char *element, int n)
|
||||
|
||||
static int php_is_dir_ok(const cwd_state *state)
|
||||
{
|
||||
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
|
||||
struct stat buf;
|
||||
|
||||
if (stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode))
|
||||
#else
|
||||
struct stat_libc buf;
|
||||
|
||||
if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISDIR(buf.st_mode))
|
||||
#endif
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
@@ -153,15 +131,9 @@ static int php_is_dir_ok(const cwd_state *state)
|
||||
|
||||
static int php_is_file_ok(const cwd_state *state)
|
||||
{
|
||||
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
|
||||
struct stat buf;
|
||||
|
||||
if (stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode))
|
||||
#else
|
||||
struct stat_libc buf;
|
||||
|
||||
if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISREG(buf.st_mode))
|
||||
#endif
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
@@ -284,7 +256,7 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC)
|
||||
|
||||
/* Resolve path relatively to state and put the real path into state */
|
||||
/* returns 0 for ok, 1 for error */
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path)
|
||||
{
|
||||
int path_length = strlen(path);
|
||||
char *ptr, *path_copy;
|
||||
@@ -302,12 +274,9 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
if (path_length == 0)
|
||||
return (0);
|
||||
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
/* cwd_length can be 0 when getcwd() fails.
|
||||
* This can happen under solaris when a dir does not have read permissions
|
||||
* but *does* have execute permissions */
|
||||
if (IS_ABSOLUTE_PATH(path, path_length) || (state->cwd_length < 1)) {
|
||||
if (use_realpath && realpath(path, resolved_path)) {
|
||||
#if !defined(TSRM_WIN32) && !defined(__BEOS__)
|
||||
if (IS_ABSOLUTE_PATH(path, path_length)) {
|
||||
if (realpath(path, resolved_path)) {
|
||||
path = resolved_path;
|
||||
path_length = strlen(path);
|
||||
}
|
||||
@@ -325,7 +294,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
memcpy(ptr, path, path_length);
|
||||
ptr += path_length;
|
||||
*ptr = '\0';
|
||||
if (use_realpath && realpath(tmp, resolved_path)) {
|
||||
if (realpath(tmp, resolved_path)) {
|
||||
path = resolved_path;
|
||||
path_length = strlen(path);
|
||||
}
|
||||
@@ -340,7 +309,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path);
|
||||
#endif
|
||||
if (IS_ABSOLUTE_PATH(path_copy, path_length)) {
|
||||
copy_amount = COPY_WHEN_ABSOLUTE(path_copy);
|
||||
copy_amount = COPY_WHEN_ABSOLUTE;
|
||||
is_absolute = 1;
|
||||
#ifdef TSRM_WIN32
|
||||
} else if (IS_UNC_PATH(path_copy, path_length)) {
|
||||
@@ -366,64 +335,53 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
}
|
||||
|
||||
|
||||
if (state->cwd_length > 0 || IS_ABSOLUTE_PATH(path, path_length)) {
|
||||
ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, &tok);
|
||||
while (ptr) {
|
||||
ptr_length = strlen(ptr);
|
||||
ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, &tok);
|
||||
while (ptr) {
|
||||
ptr_length = strlen(ptr);
|
||||
|
||||
if (IS_DIRECTORY_UP(ptr, ptr_length)) {
|
||||
char save;
|
||||
if (IS_DIRECTORY_UP(ptr, ptr_length)) {
|
||||
char save;
|
||||
|
||||
save = DEFAULT_SLASH;
|
||||
save = DEFAULT_SLASH;
|
||||
|
||||
#define PREVIOUS state->cwd[state->cwd_length - 1]
|
||||
|
||||
while (IS_ABSOLUTE_PATH(state->cwd, state->cwd_length) &&
|
||||
!IS_SLASH(PREVIOUS)) {
|
||||
save = PREVIOUS;
|
||||
PREVIOUS = '\0';
|
||||
state->cwd_length--;
|
||||
}
|
||||
|
||||
if (!IS_ABSOLUTE_PATH(state->cwd, state->cwd_length)) {
|
||||
state->cwd[state->cwd_length++] = save;
|
||||
state->cwd[state->cwd_length] = '\0';
|
||||
} else {
|
||||
PREVIOUS = '\0';
|
||||
state->cwd_length--;
|
||||
}
|
||||
} else if (!IS_DIRECTORY_CURRENT(ptr, ptr_length)) {
|
||||
state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1+1);
|
||||
#ifdef TSRM_WIN32
|
||||
/* Windows 9x will consider C:\\Foo as a network path. Avoid it. */
|
||||
if ((state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') ||
|
||||
IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
|
||||
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
|
||||
}
|
||||
#elif defined(NETWARE)
|
||||
/* If the token is a volume name, it will have colon at the end -- so, no slash before it */
|
||||
if (ptr[ptr_length-1] != ':') {
|
||||
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
|
||||
}
|
||||
#else
|
||||
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
|
||||
#endif
|
||||
memcpy(&state->cwd[state->cwd_length], ptr, ptr_length+1);
|
||||
state->cwd_length += ptr_length;
|
||||
while (IS_ABSOLUTE_PATH(state->cwd, state->cwd_length) &&
|
||||
!IS_SLASH(PREVIOUS)) {
|
||||
save = PREVIOUS;
|
||||
PREVIOUS = '\0';
|
||||
state->cwd_length--;
|
||||
}
|
||||
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
|
||||
}
|
||||
|
||||
if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) {
|
||||
state->cwd = (char *) realloc(state->cwd, state->cwd_length+1+1);
|
||||
state->cwd[state->cwd_length] = DEFAULT_SLASH;
|
||||
state->cwd[state->cwd_length+1] = '\0';
|
||||
state->cwd_length++;
|
||||
if (!IS_ABSOLUTE_PATH(state->cwd, state->cwd_length)) {
|
||||
state->cwd[state->cwd_length++] = save;
|
||||
state->cwd[state->cwd_length] = '\0';
|
||||
} else {
|
||||
PREVIOUS = '\0';
|
||||
state->cwd_length--;
|
||||
}
|
||||
} else if (!IS_DIRECTORY_CURRENT(ptr, ptr_length)) {
|
||||
state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1+1);
|
||||
#ifdef TSRM_WIN32
|
||||
/* Windows 9x will consider C:\\Foo as a network path. Avoid it. */
|
||||
if ((state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') ||
|
||||
IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
|
||||
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
|
||||
}
|
||||
#else
|
||||
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
|
||||
#endif
|
||||
memcpy(&state->cwd[state->cwd_length], ptr, ptr_length+1);
|
||||
state->cwd_length += ptr_length;
|
||||
}
|
||||
} else {
|
||||
state->cwd = (char *) realloc(state->cwd, path_length+1);
|
||||
memcpy(state->cwd, path, path_length+1);
|
||||
state->cwd_length = path_length;
|
||||
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
|
||||
}
|
||||
|
||||
if (state->cwd_length == COPY_WHEN_ABSOLUTE) {
|
||||
state->cwd = (char *) realloc(state->cwd, state->cwd_length+1+1);
|
||||
state->cwd[state->cwd_length] = DEFAULT_SLASH;
|
||||
state->cwd[state->cwd_length+1] = '\0';
|
||||
state->cwd_length++;
|
||||
}
|
||||
|
||||
if (verify_path && verify_path(state)) {
|
||||
@@ -448,7 +406,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
|
||||
CWD_API int virtual_chdir(const char *path TSRMLS_DC)
|
||||
{
|
||||
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, 1)?-1:0;
|
||||
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok)?-1:0;
|
||||
}
|
||||
|
||||
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC)
|
||||
@@ -469,7 +427,7 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (length == COPY_WHEN_ABSOLUTE(path) && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
|
||||
if (length == COPY_WHEN_ABSOLUTE && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
|
||||
length++;
|
||||
}
|
||||
temp = (char *) tsrm_do_alloca(length+1);
|
||||
@@ -486,23 +444,19 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
|
||||
CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
char *retval;
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
retval = virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
if (virtual_file_ex(&new_state, path, NULL, 1)==0) {
|
||||
if (!retval) {
|
||||
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
|
||||
|
||||
memcpy(real_path, new_state.cwd, len);
|
||||
real_path[len] = '\0';
|
||||
retval = real_path;
|
||||
} else {
|
||||
retval = NULL;
|
||||
return real_path;
|
||||
}
|
||||
|
||||
CWD_STATE_FREE(&new_state);
|
||||
|
||||
return retval;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC)
|
||||
@@ -511,7 +465,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
retval = virtual_file_ex(&new_state, path, verify_path, 1);
|
||||
retval = virtual_file_ex(&new_state, path, verify_path);
|
||||
|
||||
*filepath = new_state.cwd;
|
||||
|
||||
@@ -534,7 +488,7 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
|
||||
}
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
f = fopen(new_state.cwd, mode);
|
||||
|
||||
@@ -542,24 +496,6 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
|
||||
return f;
|
||||
}
|
||||
|
||||
#if !defined(TSRM_WIN32)
|
||||
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 1);
|
||||
|
||||
ret = access(new_state.cwd, mode);
|
||||
|
||||
CWD_STATE_FREE(&new_state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_UTIME
|
||||
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
|
||||
{
|
||||
@@ -567,7 +503,7 @@ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, filename, NULL, 0);
|
||||
virtual_file_ex(&new_state, filename, NULL);
|
||||
|
||||
ret = utime(new_state.cwd, buf);
|
||||
|
||||
@@ -582,7 +518,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC)
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, filename, NULL, 1);
|
||||
virtual_file_ex(&new_state, filename, NULL);
|
||||
|
||||
ret = chmod(new_state.cwd, mode);
|
||||
|
||||
@@ -590,14 +526,14 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#ifndef TSRM_WIN32
|
||||
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
int ret;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, filename, NULL, 0);
|
||||
virtual_file_ex(&new_state, filename, NULL);
|
||||
|
||||
ret = chown(new_state.cwd, owner, group);
|
||||
|
||||
@@ -612,7 +548,7 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...)
|
||||
int f;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
if (flags & O_CREAT) {
|
||||
mode_t mode;
|
||||
@@ -636,7 +572,7 @@ CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC)
|
||||
int f;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
f = creat(new_state.cwd, mode);
|
||||
|
||||
@@ -651,11 +587,11 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&old_state, &CWDG(cwd));
|
||||
virtual_file_ex(&old_state, oldname, NULL, 0);
|
||||
virtual_file_ex(&old_state, oldname, NULL);
|
||||
oldname = old_state.cwd;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, newname, NULL, 0);
|
||||
virtual_file_ex(&new_state, newname, NULL);
|
||||
newname = new_state.cwd;
|
||||
|
||||
retval = rename(oldname, newname);
|
||||
@@ -666,50 +602,36 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
|
||||
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = stat(new_state.cwd, buf);
|
||||
|
||||
CWD_STATE_FREE(&new_state);
|
||||
return retval;
|
||||
}
|
||||
#else
|
||||
CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 1);
|
||||
#ifndef TSRM_WIN32
|
||||
|
||||
retval = stat(new_state.cwd, (struct stat*)buf);
|
||||
|
||||
CWD_STATE_FREE(&new_state);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
|
||||
{
|
||||
cwd_state new_state;
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 0);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = lstat(new_state.cwd, buf);
|
||||
|
||||
CWD_STATE_FREE(&new_state);
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
CWD_API int virtual_unlink(const char *path TSRMLS_DC)
|
||||
@@ -718,7 +640,7 @@ CWD_API int virtual_unlink(const char *path TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, path, NULL, 0);
|
||||
virtual_file_ex(&new_state, path, NULL);
|
||||
|
||||
retval = unlink(new_state.cwd);
|
||||
|
||||
@@ -732,7 +654,7 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 1);
|
||||
virtual_file_ex(&new_state, pathname, NULL);
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
retval = mkdir(new_state.cwd);
|
||||
@@ -749,7 +671,7 @@ CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC)
|
||||
int retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 0);
|
||||
virtual_file_ex(&new_state, pathname, NULL);
|
||||
|
||||
retval = rmdir(new_state.cwd);
|
||||
|
||||
@@ -767,7 +689,7 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
|
||||
DIR *retval;
|
||||
|
||||
CWD_STATE_COPY(&new_state, &CWDG(cwd));
|
||||
virtual_file_ex(&new_state, pathname, NULL, 1);
|
||||
virtual_file_ex(&new_state, pathname, NULL);
|
||||
|
||||
retval = opendir(new_state.cwd);
|
||||
|
||||
@@ -775,45 +697,7 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
|
||||
{
|
||||
return popen_ex(command, type, CWDG(cwd).cwd, NULL);
|
||||
}
|
||||
|
||||
#elif defined(NETWARE)
|
||||
|
||||
/* On NetWare, the trick of prepending "cd cwd; " doesn't work so we need to perform
|
||||
a VCWD_CHDIR() and mutex it
|
||||
*/
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
|
||||
{
|
||||
char prev_cwd[MAXPATHLEN];
|
||||
char *getcwd_result;
|
||||
FILE *retval;
|
||||
|
||||
getcwd_result = VCWD_GETCWD(prev_cwd, MAXPATHLEN);
|
||||
if (!getcwd_result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_lock(cwd_mutex);
|
||||
#endif
|
||||
|
||||
VCWD_CHDIR(CWDG(cwd).cwd);
|
||||
retval = popen(command, type);
|
||||
VCWD_CHDIR(prev_cwd);
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_unlock(cwd_mutex);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else /* Unix */
|
||||
#ifndef TSRM_WIN32
|
||||
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
|
||||
{
|
||||
@@ -849,6 +733,37 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* On Windows the trick of prepending "cd cwd; " doesn't work so we need to perform
|
||||
a real chdir() and mutex it
|
||||
*/
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
|
||||
{
|
||||
char prev_cwd[MAXPATHLEN];
|
||||
char *getcwd_result;
|
||||
FILE *retval;
|
||||
|
||||
getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
|
||||
if (!getcwd_result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_lock(cwd_mutex);
|
||||
#endif
|
||||
|
||||
chdir(CWDG(cwd).cwd);
|
||||
retval = popen(command, type);
|
||||
chdir(prev_cwd);
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_unlock(cwd_mutex);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+13
-66
@@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -41,10 +41,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__osf__) || defined(_AIX)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
#include "readdir.h"
|
||||
#include <sys/utime.h>
|
||||
@@ -56,29 +52,12 @@ typedef unsigned short mode_t;
|
||||
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
|
||||
#define IS_SLASH_P(c) (*(c) == '/' || \
|
||||
(*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
|
||||
|
||||
/* COPY_WHEN_ABSOLUTE also takes path as argument because netware needs it
|
||||
* to account for volume name that is unique to NetWare absolute paths
|
||||
*/
|
||||
#define COPY_WHEN_ABSOLUTE(path) 2
|
||||
#define COPY_WHEN_ABSOLUTE 2
|
||||
#define IS_ABSOLUTE_PATH(path, len) \
|
||||
(len >= 2 && ((isalpha(path[0]) && path[1] == ':') || (IS_SLASH(path[0]) && IS_SLASH(path[1]))))
|
||||
(len >= 2 && isalpha(path[0]) && path[1] == ':')
|
||||
#define IS_UNC_PATH(path, len) \
|
||||
(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
|
||||
|
||||
#elif defined(NETWARE)
|
||||
#ifdef HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#define DEFAULT_SLASH '/'
|
||||
#define DEFAULT_DIR_SEPARATOR ';'
|
||||
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
|
||||
#define COPY_WHEN_ABSOLUTE(path) \
|
||||
(strchr(path, ':') - path + 1) /* Take the volume name which ends with a colon */
|
||||
#define IS_ABSOLUTE_PATH(path, len) \
|
||||
(strchr(path, ':') != NULL) /* Colon indicates volume name */
|
||||
|
||||
#else
|
||||
#ifdef HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
@@ -99,7 +78,7 @@ typedef unsigned short mode_t;
|
||||
|
||||
|
||||
#ifndef COPY_WHEN_ABSOLUTE
|
||||
#define COPY_WHEN_ABSOLUTE(path) 0
|
||||
#define COPY_WHEN_ABSOLUTE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS_ABSOLUTE_PATH
|
||||
@@ -141,12 +120,8 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC);
|
||||
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
|
||||
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
|
||||
CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC);
|
||||
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
|
||||
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
|
||||
#else
|
||||
CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC);
|
||||
#endif
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#ifndef TSRM_WIN32
|
||||
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
|
||||
#endif
|
||||
CWD_API int virtual_unlink(const char *path TSRMLS_DC);
|
||||
@@ -154,39 +129,15 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC);
|
||||
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC);
|
||||
CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC);
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
|
||||
|
||||
#if !defined(TSRM_WIN32)
|
||||
CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
/* On AIX & Tru64 when a file does not exist realpath() returns
|
||||
* NULL, and sets errno to ENOENT. Unlike in other libc implementations
|
||||
* the destination is not filled and remains undefined. Therefor, we
|
||||
* must populate it manually using strcpy as done on systems with no
|
||||
* realpath() function.
|
||||
*/
|
||||
#if defined(__osf__) || defined(_AIX)
|
||||
static char *php_realpath_hack(char *src, char *dest)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if ((ret = realpath(src, dest)) == NULL && errno == ENOENT) {
|
||||
return strcpy(dest, src);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_UTIME
|
||||
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
|
||||
#endif
|
||||
CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#ifndef TSRM_WIN32
|
||||
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath);
|
||||
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
|
||||
|
||||
typedef struct _virtual_cwd_globals {
|
||||
cwd_state cwd;
|
||||
@@ -217,7 +168,9 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC)
|
||||
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
|
||||
#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#ifdef TSRM_WIN32
|
||||
#define VCWD_LSTAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
|
||||
#else
|
||||
#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
|
||||
#endif
|
||||
#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC)
|
||||
@@ -225,12 +178,11 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC)
|
||||
#define VCWD_OPENDIR(pathname) virtual_opendir(pathname TSRMLS_CC)
|
||||
#define VCWD_POPEN(command, type) virtual_popen(command, type TSRMLS_CC)
|
||||
#define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode TSRMLS_CC)
|
||||
#if HAVE_UTIME
|
||||
#define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
|
||||
#endif
|
||||
#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC)
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#ifndef TSRM_WIN32
|
||||
#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group TSRMLS_CC)
|
||||
#endif
|
||||
|
||||
@@ -252,14 +204,9 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_RMDIR(pathname) rmdir(pathname)
|
||||
#define VCWD_OPENDIR(pathname) opendir(pathname)
|
||||
#define VCWD_POPEN(command, type) popen(command, type)
|
||||
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
|
||||
|
||||
#ifdef HAVE_REALPATH
|
||||
#if defined(__osf__) || defined(_AIX)
|
||||
#define VCWD_REALPATH(path, real_path) php_realpath_hack(path, real_path)
|
||||
#else
|
||||
#ifndef TSRM_WIN32
|
||||
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
|
||||
#endif
|
||||
#else
|
||||
#define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
|
||||
#endif
|
||||
@@ -268,7 +215,7 @@ typedef struct _virtual_cwd_globals {
|
||||
#define VCWD_UTIME(path, time) utime(path, time)
|
||||
#endif
|
||||
#define VCWD_CHMOD(path, mode) chmod(path, mode)
|
||||
#if !defined(TSRM_WIN32) && !defined(NETWARE)
|
||||
#ifndef TSRM_WIN32
|
||||
#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
|
||||
#endif
|
||||
|
||||
|
||||
+4
-7
@@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "TSRM.h"
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
#include <windows.h>
|
||||
#include "tsrm_win32.h"
|
||||
|
||||
#ifdef ZTS
|
||||
@@ -148,11 +150,6 @@ static HANDLE dupHandle(HANDLE fh, BOOL inherit) {
|
||||
}
|
||||
|
||||
TSRM_API FILE *popen(const char *command, const char *type)
|
||||
{
|
||||
return popen_ex(command, type, NULL, NULL);
|
||||
}
|
||||
|
||||
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env)
|
||||
{
|
||||
FILE *stream = NULL;
|
||||
int fno, str_len = strlen(type), read, mode;
|
||||
@@ -195,7 +192,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
|
||||
|
||||
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c "));
|
||||
sprintf(cmd, "%s /c %s", TWG(comspec), command);
|
||||
if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, env, cwd, &startup, &process)) {
|
||||
if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &process)) {
|
||||
return NULL;
|
||||
}
|
||||
free(cmd);
|
||||
|
||||
+5
-2
@@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -22,6 +22,8 @@
|
||||
#define TSRM_WIN32_H
|
||||
|
||||
#include "TSRM.h"
|
||||
|
||||
#ifdef TSRM_WIN32
|
||||
#include <windows.h>
|
||||
|
||||
struct ipc_perm {
|
||||
@@ -71,6 +73,8 @@ typedef struct {
|
||||
# define TWG(v) (win32_globals.v)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define IPC_PRIVATE 0
|
||||
#define IPC_CREAT 00001000
|
||||
#define IPC_EXCL 00002000
|
||||
@@ -92,7 +96,6 @@ typedef struct {
|
||||
TSRM_API void tsrm_win32_startup(void);
|
||||
TSRM_API void tsrm_win32_shutdown(void);
|
||||
|
||||
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
|
||||
TSRM_API FILE *popen(const char *command, const char *type);
|
||||
TSRM_API int pclose(FILE *stream);
|
||||
|
||||
|
||||
+358
-893
File diff suppressed because it is too large.
Load diff
+280
@@ -0,0 +1,280 @@
|
||||
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.
|
||||
|
||||
If you do not pass the structure as an argument you can always fetch it by
|
||||
using the appropriate ???LS_FETCH() macros within a functions variable
|
||||
declarations.
|
||||
|
||||
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 "bar" 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
@@ -0,0 +1,492 @@
|
||||
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
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#! /bin/sh
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# cwd must be top_srcdir
|
||||
test -f build/bsd_makefile || exit 2
|
||||
|
||||
test -f bsd_converted && exit 0
|
||||
|
||||
tmpfile=`mktemp /tmp/bsd_makefile.XXXXXX 2>/dev/null` || tmpfile="tmp.$$"
|
||||
for i in build/*.mk; do
|
||||
sed 's/^include \(.*\)/.include "\1"/' $i >$tmpfile \
|
||||
&& cp $tmpfile $i
|
||||
done
|
||||
rm -f $tmpfile
|
||||
|
||||
touch bsd_converted
|
||||
exit 0
|
||||
+8
-10
@@ -20,27 +20,24 @@
|
||||
# Makefile to generate build tools
|
||||
#
|
||||
|
||||
ZENDDIR = Zend
|
||||
|
||||
SUBDIRS = $(ZENDDIR) TSRM
|
||||
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 = $(ZENDDIR)/Makefile.am \
|
||||
@echo makefile_am_files = Zend/Makefile.am \
|
||||
TSRM/Makefile.am > $@
|
||||
@echo config_h_files = $(ZENDDIR)/acconfig.h TSRM/acconfig.h >> $@
|
||||
@echo config_m4_files = $(ZENDDIR)/Zend.m4 TSRM/tsrm.m4 TSRM/threads.m4 \
|
||||
$(ZENDDIR)/acinclude.m4 ext/*/config*.m4 sapi/*/config.m4 >> $@
|
||||
@echo config_h_files = Zend/acconfig.h TSRM/acconfig.h >> $@
|
||||
@echo config_m4_files = Zend/Zend.m4 TSRM/tsrm.m4 TSRM/threads.m4 \
|
||||
Zend/acinclude.m4 ext/*/config*.m4 sapi/*/config.m4 >> $@
|
||||
|
||||
$(STAMP): build/buildcheck.sh
|
||||
@build/buildcheck.sh $(STAMP)
|
||||
@build/buildcheck.sh && touch $(STAMP)
|
||||
|
||||
snapshot:
|
||||
distname='$(DISTNAME)'; \
|
||||
@@ -67,7 +64,8 @@ snapshot:
|
||||
|
||||
cvsclean:
|
||||
@for i in `find . -name .cvsignore`; do \
|
||||
(cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore | grep -v config.nice` *.o *.a .libs || true); \
|
||||
(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
|
||||
+24
-11
@@ -30,16 +30,37 @@ config_h_in = main/php_config.h.in
|
||||
|
||||
acconfig_h_SOURCES = acconfig.h.in $(config_h_files)
|
||||
|
||||
targets = $(TOUCH_FILES) configure $(config_h_in)
|
||||
targets = $(TOUCH_FILES) $(makefile_in_files) configure $(config_h_in)
|
||||
|
||||
|
||||
all: $(targets)
|
||||
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) > $@
|
||||
|
||||
SUPPRESS_WARNINGS = (egrep -v '(AC_TRY_RUN called without default to allow cross compiling|AC_PROG_CXXCPP was called before AC_PROG_CXX|defined in acinclude.m4 but never used|AC_PROG_LEX invoked multiple times)'||true)
|
||||
$(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) 2>&1 | $(SUPPRESS_WARNINGS)
|
||||
@for i in $(LT_TARGETS); do mv $$i.bak $$i; done
|
||||
|
||||
aclocal.m4: configure.in acinclude.m4 dynlib.m4
|
||||
aclocal 2>&1 | $(SUPPRESS_WARNINGS)
|
||||
|
||||
SUPPRESS_WARNINGS = (egrep -v '(AC_TRY_RUN called without default to allow cross compiling|AC_PROG_CXXCPP was called before AC_PROG_CXX|.*AM_PROG_LEX.*|defined in acinclude.m4 but never used|AC_PROG_LEX invoked multiple times|AC_PROG_CPP was called before)'||true)
|
||||
|
||||
$(config_h_in): configure acconfig.h
|
||||
# explicitly remove target since autoheader does not seem to work
|
||||
@@ -51,14 +72,6 @@ $(config_h_in): configure acconfig.h
|
||||
$(TOUCH_FILES):
|
||||
touch $(TOUCH_FILES)
|
||||
|
||||
aclocal.m4: configure.in acinclude.m4
|
||||
@echo rebuilding $@
|
||||
@libtoolize=`./build/shtool path glibtoolize libtoolize`; \
|
||||
$$libtoolize --copy --automake; \
|
||||
ltpath=`dirname $$libtoolize`; \
|
||||
ltfile=`cd $$ltpath/../share/aclocal; pwd`/libtool.m4; \
|
||||
cat acinclude.m4 $$ltfile > $@
|
||||
|
||||
configure: aclocal.m4 configure.in $(config_m4_files)
|
||||
@echo rebuilding $@
|
||||
@autoconf 2>&1 | $(SUPPRESS_WARNINGS)
|
||||
+36
-36
@@ -12,17 +12,15 @@
|
||||
# | obtain it through the world-wide-web, please send a note to |
|
||||
# | license@php.net so we can mail you a copy immediately. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Authors: Stig Bakken <ssb@php.net> |
|
||||
# | Authors: Stig Bakken <ssb@fast.no> |
|
||||
# | Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id: buildcheck.sh,v 1.21.2.5 2003-07-01 04:25:32 sas Exp $
|
||||
# $Id: buildcheck.sh,v 1.16 2002-03-04 08:28:57 sas Exp $
|
||||
#
|
||||
|
||||
echo "buildconf: checking installation..."
|
||||
|
||||
stamp=$1
|
||||
|
||||
# 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
|
||||
@@ -42,52 +40,54 @@ echo "buildconf: autoconf version $ac_version (ok)"
|
||||
fi
|
||||
|
||||
|
||||
if test "$1" = "2" && test "$2" -ge "50"; then
|
||||
echo "buildconf: Your version of autoconf likely contains buggy cache code."
|
||||
echo " Running cvsclean for you."
|
||||
echo " To avoid this, install autoconf-2.13 and automake-1.5."
|
||||
./cvsclean
|
||||
stamp=
|
||||
fi
|
||||
|
||||
# libtoolize 1.4.3 or newer
|
||||
# Prefer glibtoolize over libtoolize for Mac OS X compatibility
|
||||
libtoolize=`./build/shtool path glibtoolize libtoolize 2> /dev/null`
|
||||
lt_pversion=`$libtoolize --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//'`
|
||||
if test "$lt_pversion" = ""; then
|
||||
echo "buildconf: libtool not found."
|
||||
echo " You need libtool version 1.4.3 or newer installed"
|
||||
# automake 1.4 or newer
|
||||
am_version=`automake --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
|
||||
am_version_clean=`echo $am_version|sed -e 's/-p[0-9]*$//'`
|
||||
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 $lt_pversion; IFS=' '
|
||||
|
||||
if test "$3" = ""; then
|
||||
third=0
|
||||
IFS=.; set $am_version_clean; 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
|
||||
third=$3
|
||||
echo "buildconf: automake version $am_version (ok)"
|
||||
fi
|
||||
|
||||
if test "$1" -gt "1" || test "$2" -ge "5" || (test "$2" -ge "4" && test "$third" -ge "3")
|
||||
# libtool 1.4 or newer
|
||||
libtool=`which libtool`
|
||||
if test ! -f "$libtool"; then libtool=`which glibtool`; fi
|
||||
lt_pversion=`$libtool --version 2>/dev/null|sed -n -e 's/^[^0-9]*//' -e 1's/[- ].*//p'`
|
||||
if test "$lt_pversion" = ""; then
|
||||
echo "buildconf: libtool not found."
|
||||
echo " You need libtool version 1.4 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" -ge "4";
|
||||
then
|
||||
echo "buildconf: libtool version $lt_pversion (ok)"
|
||||
else
|
||||
echo "buildconf: libtool version $lt_pversion found."
|
||||
echo " You need libtool version 1.4.3 or newer installed"
|
||||
echo " You need libtool version 1.4 or newer installed"
|
||||
echo " to build PHP from CVS."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ltpath=`echo $libtoolize | sed -e 's#/[^/]*/[^/]*$##'`
|
||||
ltfile="$ltpath/share/aclocal/libtool.m4"
|
||||
if test -r "$ltfile"; then
|
||||
:
|
||||
else
|
||||
echo "buildconf: $ltfile does not exist."
|
||||
echo " Please reinstall libtool."
|
||||
exit 1
|
||||
am_prefix=`which automake | sed -e 's#/[^/]*/[^/]*$##'`
|
||||
lt_prefix=`echo $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
|
||||
|
||||
test -n "$stamp" && touch $stamp
|
||||
|
||||
exit 0
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id$
|
||||
|
||||
dir=$1; shift
|
||||
for stubfile in $dir/*/config0.m4 $dir/*/config.m4 $dir/*/config9.m4; do
|
||||
echo "sinclude($stubfile)"
|
||||
done
|
||||
@@ -0,0 +1,24 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
all: all-recursive
|
||||
|
||||
include $(builddir)/libs.mk
|
||||
|
||||
include $(top_srcdir)/build/rules.mk
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id: fastgen.sh,v 1.14 2002-02-28 08:25:33 sebastian Exp $
|
||||
#
|
||||
|
||||
if test "$#" = "0"; then
|
||||
echo "Usage: fastgen.sh <srcdir> <mkdir_p> <bsdmakefile_p> <file>"
|
||||
fi
|
||||
|
||||
srcdir=$1
|
||||
shift
|
||||
|
||||
mkdir_p=$1
|
||||
shift
|
||||
|
||||
bsd_makefile=$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/build/shtool mkdir -p"
|
||||
fi
|
||||
|
||||
if test "$bsd_makefile" = "yes"; then
|
||||
(cd $top_srcdir; ./build/bsd_makefile)
|
||||
|
||||
for makefile in $@; do
|
||||
echo "fastgen.sh: creating $makefile"
|
||||
dir=`echo $makefile|sed 's%/*[^/][^/]*$%%'`
|
||||
$mkdir_p "$dir/"
|
||||
|
||||
cat - $top_srcdir/$makefile.in <<EOF |sed 's/^include \(.*\)/.include "\1"/' >$makefile
|
||||
top_srcdir = $top_srcdir
|
||||
top_builddir = $top_builddir
|
||||
srcdir = $top_srcdir/$dir
|
||||
builddir = $top_builddir/$dir
|
||||
VPATH = $top_srcdir/$dir
|
||||
EOF
|
||||
|
||||
test -z "$dir" && dir=.
|
||||
touch $dir/.deps
|
||||
done
|
||||
else
|
||||
for makefile in $@; do
|
||||
echo "fastgen.sh: creating $makefile"
|
||||
dir=`echo $makefile|sed 's%/*[^/][^/]*$%%'`
|
||||
$mkdir_p "$dir/"
|
||||
|
||||
cat - $top_srcdir/$makefile.in <<EOF >$makefile
|
||||
top_srcdir = $top_srcdir
|
||||
top_builddir = $top_builddir
|
||||
srcdir = $top_srcdir/$dir
|
||||
builddir = $top_builddir/$dir
|
||||
VPATH = $top_srcdir/$dir
|
||||
EOF
|
||||
|
||||
test -z "$dir" && dir=.
|
||||
touch $dir/.deps
|
||||
done
|
||||
fi
|
||||
+8
-8
@@ -1,24 +1,24 @@
|
||||
#! /bin/sh
|
||||
|
||||
# $Id: genif.sh,v 1.3 2002-03-22 10:22:41 sas Exp $
|
||||
# $Id: genif.sh,v 1.2 2001-03-30 14:02:20 sas Exp $
|
||||
# replacement for genif.pl
|
||||
|
||||
infile=$1
|
||||
infile="$1"
|
||||
shift
|
||||
srcdir=$1
|
||||
srcdir="$1"
|
||||
shift
|
||||
extra_module_ptrs=$1
|
||||
extra_module_ptrs="$1"
|
||||
shift
|
||||
awk=$1
|
||||
awk="$1"
|
||||
shift
|
||||
|
||||
if test -z "$infile" || test -z "$srcdir"; then
|
||||
if test "$infile" = "" -o "$srcdir" = ""; then
|
||||
echo "please supply infile and srcdir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
module_ptrs=$extra_module_ptrs
|
||||
header_list=
|
||||
module_ptrs="$extra_module_ptrs"
|
||||
header_list=""
|
||||
olddir=`pwd`
|
||||
cd $srcdir
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
LTLIBRARY_OBJECTS = $(LTLIBRARY_SOURCES:.c=.lo) $(LTLIBRARY_OBJECTS_X)
|
||||
|
||||
$(LTLIBRARY_NAME): $(LTLIBRARY_OBJECTS) $(LTLIBRARY_DEPENDENCIES)
|
||||
$(LINK) $(LTLIBRARY_LDFLAGS) $(LTLIBRARY_OBJECTS) $(LTLIBRARY_LIBADD)
|
||||
@@ -0,0 +1,24 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
targets = $(LTLIBRARY_NAME)
|
||||
|
||||
include $(top_srcdir)/build/rules.mk
|
||||
include $(top_srcdir)/build/library.mk
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
PROGRAM_OBJECTS = $(PROGRAM_SOURCES:.c=.lo)
|
||||
|
||||
$(PROGRAM_NAME): $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS)
|
||||
$(LINK_CLEAN) $(PROGRAM_LDFLAGS) $(PROGRAM_OBJECTS) $(PROGRAM_LDADD)
|
||||
@@ -0,0 +1,70 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/build/rules_common.mk
|
||||
|
||||
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
|
||||
@echo $(top_srcdir) $(top_builddir) $(srcdir) $(CPP) $(INCLUDES) $(EXTRA_INCLUDES) $(DEFS) $(CPPFLAGS) $(srcdir)/*.c *.c | $(AWK) -f $(top_srcdir)/build/mkdep.awk > $(builddir)/.deps || true
|
||||
|
||||
clean: clean-modules clean-recursive clean-x
|
||||
|
||||
clean-modules:
|
||||
|
||||
clean-x:
|
||||
rm -f $(targets) *.lo *.slo *.la *.o $(CLEANFILES)
|
||||
rm -rf .libs 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
|
||||
|
||||
test: $(top_builddir)/sapi/cli/php
|
||||
@if test "$(TESTS)" = ""; then \
|
||||
TOP_BUILDDIR=$(top_builddir) TOP_SRCDIR=$(top_srcdir) $(top_builddir)/sapi/cli/php -c $(top_srcdir)/php.ini-dist $(top_srcdir)/run-tests.php $(srcdir); \
|
||||
else \
|
||||
TOP_BUILDDIR=$(top_builddir) TOP_SRCDIR=$(top_srcdir) $(top_builddir)/sapi/cli/php -c $(top_srcdir)/php.ini-dist $(top_srcdir)/run-tests.php $(TESTS); \
|
||||
fi
|
||||
|
||||
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
|
||||
@@ -0,0 +1,77 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
include $(top_builddir)/config_vars.mk
|
||||
|
||||
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS)
|
||||
COMPILE = $(CC) $(COMMON_FLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
|
||||
CXX_COMPILE = $(CXX) $(COMMON_FLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS)
|
||||
|
||||
SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) -prefer-pic $(EXTRA_CFLAGS) -c $< && touch $@
|
||||
CXX_SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(CXX) $(COMMON_FLAGS) $(CXXFLAGS_CLEAN) -prefer-pic $(EXTRA_CXXFLAGS) -c $< && touch $@
|
||||
|
||||
LINK = $(LIBTOOL) --mode=link $(COMPILE) $(LDFLAGS) -o $@
|
||||
LINK_CLEAN = $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
|
||||
INSTALL = $(top_srcdir)/build/shtool install -c
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
DEFS = -I. -I$(srcdir) -I$(top_builddir)/main -I$(top_srcdir)
|
||||
|
||||
moduledir = $(EXTENSION_DIR)
|
||||
|
||||
CXX_SUFFIX = .cpp
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .slo .c $(CXX_SUFFIX) .lo .o .s .y .l
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
$(CXX_SUFFIX).o:
|
||||
$(CXX_COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c.lo:
|
||||
$(PHP_COMPILE)
|
||||
|
||||
$(CXX_SUFFIX).lo:
|
||||
$(CXX_PHP_COMPILE)
|
||||
|
||||
.s.lo:
|
||||
$(PHP_COMPILE)
|
||||
|
||||
.c.slo:
|
||||
$(SHARED_COMPILE)
|
||||
|
||||
$(CXX_SUFFIX).slo:
|
||||
$(CXX_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 $@
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/build/rules_common.mk
|
||||
|
||||
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
|
||||
@echo $(top_srcdir) $(top_builddir) $(srcdir) $(CPP) $(INCLUDES) $(EXTRA_INCLUDES) $(DEFS) $(CPPFLAGS) $(srcdir)/*.c *.c | $(AWK) -f $(top_srcdir)/build/mkdep.awk > $(builddir)/.deps || true
|
||||
|
||||
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 \
|
||||
config.h stamp-h Makefile build-defs.h php4.spec libphp4.module
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
+136
-466
@@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
##
|
||||
## GNU shtool -- The GNU Portable Shell Tool
|
||||
## Copyright (c) 1994-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## 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.6.2 (02-Nov-2002)
|
||||
## Contents: 4/19 available modules
|
||||
## Version 1.4.9 (16-Apr-2000)
|
||||
## Ingredients: 3/17 available modules
|
||||
##
|
||||
|
||||
##
|
||||
@@ -26,7 +26,7 @@
|
||||
## 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
|
||||
## 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
|
||||
@@ -41,7 +41,6 @@
|
||||
## echo Print string with optional construct expansion
|
||||
## install Install a program, script or datafile
|
||||
## mkdir Make one or more directories
|
||||
## path Deal with program paths
|
||||
##
|
||||
## Not available commands (because module was not built-in):
|
||||
## mdate Pretty-print modification time of a file or dir
|
||||
@@ -51,14 +50,13 @@
|
||||
## mkln Make link with calculation of relative paths
|
||||
## mkshadow Make a shadow tree through symbolic links
|
||||
## fixperm Fix file permissions inside a source tree
|
||||
## rotate Logfile rotation
|
||||
## tarball Roll distribution tarballs
|
||||
## subst Apply sed(1) substitution operations
|
||||
## guessos Simple operating system guesser
|
||||
## arx Extended archive command
|
||||
## slo Separate linker options by library class
|
||||
## scpp Sharing C Pre-Processor
|
||||
## version Maintain a version information file
|
||||
## version Generate and maintain a version information file
|
||||
## path Deal with program paths
|
||||
##
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -67,76 +65,46 @@ if [ $# -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
|
||||
echo "This is GNU shtool, version 1.6.2 (02-Nov-2002)"
|
||||
echo "Copyright (c) 1994-2002 Ralf S. Engelschall <rse@engelschall.com>"
|
||||
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 "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 ' -r, --recreate recreate this shtool script via shtoolize'
|
||||
echo ''
|
||||
echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
|
||||
echo ' echo [-n|--newline] [-e|--expand] [<str> ...]'
|
||||
echo ' install [-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy]'
|
||||
echo ' [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>]'
|
||||
echo ' [-o|--owner <owner>] [-g|--group <group>] [-e|--exec'
|
||||
echo ' <sed-cmd>] <file> [<file> ...] <path>'
|
||||
echo ' mkdir [-t|--trace] [-f|--force] [-p|--parents] [-m|--mode'
|
||||
echo ' <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir>'
|
||||
echo ' [<dir> ...]'
|
||||
echo ' path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename]'
|
||||
echo ' [-m|--magic] [-p|--path <path>] <str> [<str> ...]'
|
||||
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|--newline] [-z|--zero] [-s|--shorten] [-d|--digits]'
|
||||
echo ' [-f|--field-sep <str>] [-o|--order <spec>] <path>'
|
||||
echo ' table [-F|--field-sep <sep>] [-w|--width <width>] [-c|--columns'
|
||||
echo ' <cols>] [-s|--strip <strip>] <str><sep><str>...'
|
||||
echo ' prop [-p|--prefix <str>]'
|
||||
echo ' move [-v|--verbose] [-t|--trace] [-e|--expand] [-p|--preserve]'
|
||||
echo ' <src-file> <dst-file>'
|
||||
echo ' mkln [-t|--trace] [-f|--force] [-s|--symbolic] <src-path>'
|
||||
echo ' [<src-path> ...] <dst-path>'
|
||||
echo ' mkshadow [-v|--verbose] [-t|--trace] [-a|--all] <src-dir> <dst-dir>'
|
||||
echo ' fixperm [-v|--verbose] [-t|--trace] <path> [<path> ...]'
|
||||
echo ' rotate [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files'
|
||||
echo ' <count>] [-s|--size <size>] [-c|--copy] [-r|--remove]'
|
||||
echo ' [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>]'
|
||||
echo ' [-b|--background] [-d|--delay] [-p|--pad <len>] [-o|--owner'
|
||||
echo ' <owner>] [-g|--group <group>] [-m|--mode <mode>] [-M|--migrate'
|
||||
echo ' <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]'
|
||||
echo ' tarball [-t|--trace] [-v|--verbose] [-o|--output <tarball>]'
|
||||
echo ' [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user'
|
||||
echo ' <user>] [-g|--group <group>] [-e|--exclude <pattern>]'
|
||||
echo ' <path> [<path> ...]'
|
||||
echo ' subst [-v|--verbose] [-t|--trace] [-n|--nop] [-s|--stealth]'
|
||||
echo ' [-i|--interactive] [-b|--backup <ext>] [-e|--exec <cmd>]'
|
||||
echo ' [-f|--file <cmd-file>] [<file>] [...]'
|
||||
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|--trace] [-C|--command <cmd>] <op> <archive> [<file>'
|
||||
echo ' ...]'
|
||||
echo ' slo [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>'
|
||||
echo ' ...]'
|
||||
echo ' scpp [-v|--verbose] [-p|--preserve] [-f|--filter <filter>]'
|
||||
echo ' [-o|--output <ofile>] [-t|--template <tfile>] [-M|--mark'
|
||||
echo ' <mark>] [-D|--define <dname>] [-C|--class <cname>]'
|
||||
echo ' <file> [<file> ...]'
|
||||
echo ' version [-l|--language <lang>] [-n|--name <name>] [-p|--prefix'
|
||||
echo ' <prefix>] [-s|--set <version>] [-e|--edit] [-i|--increase'
|
||||
echo ' <knob>] [-d|--display <type>] <file>'
|
||||
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.6.2 (02-Nov-2002)"
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
|
||||
shtoolize -oshtool echo install mkdir path
|
||||
echo "GNU shtool 1.4.9 (16-Apr-2000)"
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
|
||||
@@ -145,7 +113,7 @@ if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
|
||||
fi
|
||||
name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
|
||||
case "$name" in
|
||||
echo|install|mkdir|path )
|
||||
echo|install|mkdir )
|
||||
# implicit tool command selection
|
||||
tool="$name"
|
||||
;;
|
||||
@@ -166,56 +134,36 @@ gen_tmpfile=no
|
||||
case $tool in
|
||||
echo )
|
||||
str_tool="echo"
|
||||
str_usage="[-n|--newline] [-e|--expand] [<str> ...]"
|
||||
str_usage="[-n] [-e] [<str> ...]"
|
||||
arg_spec="0+"
|
||||
opt_spec="n.e."
|
||||
opt_alias="n:newline,e:expand"
|
||||
opt_n=no
|
||||
opt_e=no
|
||||
;;
|
||||
install )
|
||||
str_tool="install"
|
||||
str_usage="[-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy] [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] [-e|--exec <sed-cmd>] <file> [<file> ...] <path>"
|
||||
arg_spec="1+"
|
||||
opt_spec="v.t.d.c.C.s.m:o:g:e+"
|
||||
opt_alias="v:verbose,t:trace,d:mkdir,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec"
|
||||
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_d=no
|
||||
opt_c=no
|
||||
opt_C=no
|
||||
opt_s=no
|
||||
opt_m="0755"
|
||||
opt_m=""
|
||||
opt_o=""
|
||||
opt_g=""
|
||||
opt_e=""
|
||||
;;
|
||||
mkdir )
|
||||
str_tool="mkdir"
|
||||
str_usage="[-t|--trace] [-f|--force] [-p|--parents] [-m|--mode <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir> [<dir> ...]"
|
||||
str_usage="[-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]"
|
||||
arg_spec="1+"
|
||||
opt_spec="t.f.p.m:o:g:"
|
||||
opt_alias="t:trace,f:force,p:parents,m:mode,o:owner,g:group"
|
||||
opt_spec="t.f.p.m:"
|
||||
opt_t=no
|
||||
opt_f=no
|
||||
opt_p=no
|
||||
opt_m=""
|
||||
opt_o=""
|
||||
opt_g=""
|
||||
;;
|
||||
path )
|
||||
str_tool="path"
|
||||
str_usage="[-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path <path>] <str> [<str> ...]"
|
||||
gen_tmpfile=yes
|
||||
arg_spec="1+"
|
||||
opt_spec="s.r.d.b.m.p:"
|
||||
opt_alias="s:suppress,r:reverse,d:dirname,b:basename,m:magic,p:path"
|
||||
opt_s=no
|
||||
opt_r=no
|
||||
opt_d=no
|
||||
opt_b=no
|
||||
opt_m=no
|
||||
opt_p="$PATH"
|
||||
;;
|
||||
-* )
|
||||
echo "$0:Error: unknown option \`$tool'" 2>&1
|
||||
@@ -233,11 +181,6 @@ esac
|
||||
## COMMON UTILITY CODE
|
||||
##
|
||||
|
||||
# commonly used ASCII values
|
||||
ASC_TAB=" "
|
||||
ASC_NL="
|
||||
"
|
||||
|
||||
# determine name of tool
|
||||
if [ ".$tool" != . ]; then
|
||||
# used inside shtool script
|
||||
@@ -259,10 +202,6 @@ eval `echo $arg_spec |\
|
||||
eval `echo h.$opt_spec |\
|
||||
sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
|
||||
|
||||
# parse option alias string
|
||||
eval `echo h:help,$opt_alias |\
|
||||
tr 'x-' 'x_' | sed -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'`
|
||||
|
||||
# interate over argument line
|
||||
opt_PREV=''
|
||||
while [ $# -gt 0 ]; do
|
||||
@@ -283,18 +222,6 @@ while [ $# -gt 0 ]; do
|
||||
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";opt_ARG="\2"/'`
|
||||
opt_STR=`echo $opt_OPT | tr 'x-' 'x_'`
|
||||
eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
|
||||
;;
|
||||
--[a-zA-Z0-9]*)
|
||||
opt_OPT=`echo "x$1" | cut -c4-`
|
||||
opt_STR=`echo $opt_OPT | tr 'x-' 'x_'`
|
||||
eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
|
||||
opt_ARG=''
|
||||
;;
|
||||
-[a-zA-Z0-9]*)
|
||||
eval `echo "x$1" |\
|
||||
sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
|
||||
@@ -334,17 +261,17 @@ while [ $# -gt 0 ]; do
|
||||
;;
|
||||
'+' )
|
||||
# option with argument (multiple occurances append)
|
||||
eval "opt_${opt_OPT}=\"\$opt_${opt_OPT}\${ASC_NL}\$opt_ARG\""
|
||||
eval "opt_${opt_OPT}=\"\$opt_${opt_OPT} \$opt_ARG\""
|
||||
;;
|
||||
* )
|
||||
echo "$msgprefix:Error: unknown option: \`$opt_OPT'" 1>&2
|
||||
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: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
|
||||
@@ -385,7 +312,6 @@ if [ ".$gen_tmpfile" = .yes ]; then
|
||||
tmpfile="$tmpdir/.shtool.$$"
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
touch $tmpfile
|
||||
chmod 600 $tmpfile
|
||||
fi
|
||||
|
||||
##
|
||||
@@ -397,7 +323,7 @@ case $tool in
|
||||
echo )
|
||||
##
|
||||
## echo -- Print string with optional construct expansion
|
||||
## Copyright (c) 1998-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for WML as buildinfo
|
||||
##
|
||||
|
||||
@@ -421,7 +347,7 @@ echo )
|
||||
fi
|
||||
|
||||
# determine terminal bold sequence
|
||||
term_bold=''
|
||||
term_bold=''
|
||||
term_norm=''
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
|
||||
case $TERM in
|
||||
@@ -430,7 +356,7 @@ echo )
|
||||
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*|cygwin)
|
||||
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`
|
||||
;;
|
||||
@@ -448,7 +374,7 @@ echo )
|
||||
fi
|
||||
done
|
||||
if [ ".$term_bold" != . ]; then
|
||||
for seq in sgr0 me rmso init reset; do # 'reset' is last
|
||||
for seq in sgr0 me rmso reset; do # 'reset' is last
|
||||
norm="`$dir/$tool $seq 2>/dev/null`"
|
||||
if [ ".$norm" != . ]; then
|
||||
term_norm="$norm"
|
||||
@@ -467,14 +393,12 @@ echo )
|
||||
esac
|
||||
if [ ".$term_bold" = . -o ".$term_norm" = . ]; then
|
||||
echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
|
||||
term_bold=''
|
||||
term_norm=''
|
||||
fi
|
||||
fi
|
||||
|
||||
# determine user name
|
||||
username=''
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uUgG]'`" != . ]; then
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then
|
||||
username="$LOGNAME"
|
||||
if [ ".$username" = . ]; then
|
||||
username="$USER"
|
||||
@@ -516,38 +440,8 @@ echo )
|
||||
fi
|
||||
fi
|
||||
|
||||
# determine (primary) group id
|
||||
groupid=''
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[gG]'`" != . ]; then
|
||||
groupid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
|
||||
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
|
||||
if [ ".$groupid" = . ]; then
|
||||
groupid=`(ypcat passwd) 2>/dev/null | egrep "^${username}:" | \
|
||||
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
|
||||
if [ ".$groupid" = . ]; then
|
||||
groupid='?'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# determine (primary) group name
|
||||
groupname=''
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%g'`" != . ]; then
|
||||
groupname=`egrep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
|
||||
sed -e 's/:.*$//'`
|
||||
if [ ".$groupname" = . ]; then
|
||||
groupname=`(ypcat group) 2>/dev/null | \
|
||||
egrep "^[^:]*:[^:]*:${groupid}:" | \
|
||||
sed -e 's/:.*$//'`
|
||||
if [ ".$groupname" = . ]; then
|
||||
groupname='?'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# determine host and domain name
|
||||
# determine host name
|
||||
hostname=''
|
||||
domainname=''
|
||||
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%h'`" != . ]; then
|
||||
hostname="`(uname -n) 2>/dev/null |\
|
||||
awk '{ printf("%s", $1); }'`"
|
||||
@@ -565,16 +459,19 @@ echo )
|
||||
;;
|
||||
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 | sed -e 'q' |\
|
||||
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 | sed -e 'q' |\
|
||||
domainname="`egrep '^[ ]*search' /etc/resolv.conf | head -1 |\
|
||||
sed -e 's/.*search//' \
|
||||
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
|
||||
-e 's/ .*//' -e 's/ .*//' \
|
||||
@@ -624,8 +521,6 @@ echo )
|
||||
-e "s/%b/${term_norm}/g" \
|
||||
-e "s/%u/${username}/g" \
|
||||
-e "s/%U/${userid}/g" \
|
||||
-e "s/%g/${groupname}/g" \
|
||||
-e "s/%G/${groupid}/g" \
|
||||
-e "s/%h/${hostname}/g" \
|
||||
-e "s/%d/${domainname}/g" \
|
||||
-e "s/%D/${time_day}/g" \
|
||||
@@ -651,168 +546,114 @@ echo )
|
||||
install )
|
||||
##
|
||||
## install -- Install a program, script or datafile
|
||||
## Copyright (c) 1997-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1997-2000 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for shtool
|
||||
##
|
||||
|
||||
# special case: "shtool install -d <dir> [...]" internally
|
||||
# maps to "shtool mkdir -f -p -m 755 <dir> [...]"
|
||||
if [ "$opt_d" = yes ]; then
|
||||
cmd="$0 mkdir -f -p -m 755"
|
||||
if [ ".$opt_o" != . ]; then
|
||||
cmd="$cmd -o '$opt_o'"
|
||||
fi
|
||||
if [ ".$opt_g" != . ]; then
|
||||
cmd="$cmd -g '$opt_g'"
|
||||
fi
|
||||
if [ ".$opt_v" = .yes ]; then
|
||||
cmd="$cmd -v"
|
||||
fi
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
cmd="$cmd -t"
|
||||
fi
|
||||
for dir in "$@"; do
|
||||
eval "$cmd $dir" || exit $?
|
||||
done
|
||||
exit 0
|
||||
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
|
||||
|
||||
# determine source(s) and destination
|
||||
argc=$#
|
||||
srcs=""
|
||||
while [ $# -gt 1 ]; do
|
||||
srcs="$srcs $1"
|
||||
shift
|
||||
done
|
||||
dstpath="$1"
|
||||
|
||||
# type check for destination
|
||||
dstisdir=0
|
||||
if [ -d $dstpath ]; then
|
||||
dstpath=`echo "$dstpath" | sed -e 's:/$::'`
|
||||
dstisdir=1
|
||||
# Add a possible extension to src and dst
|
||||
if [ ".$opt_e" != . ]; then
|
||||
src="$src$opt_e"
|
||||
dst="$dst$opt_e"
|
||||
fi
|
||||
|
||||
# consistency check for destination
|
||||
if [ $argc -gt 2 -a $dstisdir = 0 ]; then
|
||||
echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2
|
||||
# Check for correct arguments
|
||||
if [ ".$src" = ".$dst" ]; then
|
||||
echo "$msgprefix:Error: source and destination are the same" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# iterate over all source(s)
|
||||
for src in $srcs; do
|
||||
dst=$dstpath
|
||||
# Make a temp file name in the destination directory
|
||||
dstdir=`echo $dst | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;'`
|
||||
dsttmp="$dstdir/#INST@$$#"
|
||||
|
||||
# if destination is a directory, append the input filename
|
||||
if [ $dstisdir = 1 ]; then
|
||||
dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
|
||||
dst="$dst/$dstfile"
|
||||
fi
|
||||
# Verbosity
|
||||
if [ ".$opt_v" = .yes ]; then
|
||||
echo "$src -> $dst" 1>&2
|
||||
fi
|
||||
|
||||
# check for correct arguments
|
||||
if [ ".$src" = ".$dst" ]; then
|
||||
echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
|
||||
continue
|
||||
# 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
|
||||
if [ -d "$src" ]; then
|
||||
echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2
|
||||
continue
|
||||
cp $src $dsttmp || exit $?
|
||||
else
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "mv $src $dsttmp" 1>&2
|
||||
fi
|
||||
mv $src $dsttmp || exit $?
|
||||
fi
|
||||
|
||||
# make a temp file name in the destination directory
|
||||
dsttmp=`echo $dst |\
|
||||
sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
|
||||
-e "s;\$;/#INST@$$#;"`
|
||||
# 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
|
||||
|
||||
# verbosity
|
||||
if [ ".$opt_v" = .yes ]; then
|
||||
echo "$src -> $dst" 1>&2
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# Finally install the file to the real destination
|
||||
if [ $quick = yes ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "rm -f $dsttmp" 1>&2
|
||||
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 $?
|
||||
rm -f $dsttmp
|
||||
else
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "rm -f $dst && mv $dsttmp $dst" 1>&2
|
||||
fi
|
||||
|
||||
# adjust the target file
|
||||
if [ ".$opt_e" != . ]; then
|
||||
sed='sed'
|
||||
OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
|
||||
for e
|
||||
do
|
||||
sed="$sed -e '$e'"
|
||||
done
|
||||
cp $dsttmp $dsttmp.old
|
||||
eval "$sed <$dsttmp.old >$dsttmp" || exit $?
|
||||
rm -f $dsttmp.old
|
||||
fi
|
||||
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
|
||||
done
|
||||
rm -f $dst && mv $dsttmp $dst
|
||||
fi
|
||||
;;
|
||||
|
||||
mkdir )
|
||||
##
|
||||
## mkdir -- Make one or more directories
|
||||
## Copyright (c) 1996-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## 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
|
||||
##
|
||||
@@ -821,7 +662,7 @@ mkdir )
|
||||
for p in ${1+"$@"}; do
|
||||
# if the directory already exists...
|
||||
if [ -d "$p" ]; then
|
||||
if [ ".$opt_f" = .no -a ".$opt_p" = .no ]; then
|
||||
if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
|
||||
echo "$msgprefix:Error: directory already exists: $p" 1>&2
|
||||
errstatus=1
|
||||
break
|
||||
@@ -835,24 +676,6 @@ mkdir )
|
||||
echo "mkdir $p" 1>&2
|
||||
fi
|
||||
mkdir $p || errstatus=$?
|
||||
if [ ".$opt_o" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chown $opt_o $p" 1>&2
|
||||
fi
|
||||
chown $opt_o $p || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_g" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chgrp $opt_g $p" 1>&2
|
||||
fi
|
||||
chgrp $opt_g $p || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_m" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chmod $opt_m $p" 1>&2
|
||||
fi
|
||||
chmod $opt_m $p || errstatus=$?
|
||||
fi
|
||||
else
|
||||
# the smart situation
|
||||
set fnord `echo ":$p" |\
|
||||
@@ -872,18 +695,6 @@ mkdir )
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
fi
|
||||
mkdir $pathcomp || errstatus=$?
|
||||
if [ ".$opt_o" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chown $opt_o $pathcomp" 1>&2
|
||||
fi
|
||||
chown $opt_o $pathcomp || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_g" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chgrp $opt_g $pathcomp" 1>&2
|
||||
fi
|
||||
chgrp $opt_g $pathcomp || errstatus=$?
|
||||
fi
|
||||
if [ ".$opt_m" != . ]; then
|
||||
if [ ".$opt_t" = .yes ]; then
|
||||
echo "chmod $opt_m $pathcomp" 1>&2
|
||||
@@ -898,147 +709,6 @@ mkdir )
|
||||
exit $errstatus
|
||||
;;
|
||||
|
||||
path )
|
||||
##
|
||||
## path -- Deal with program paths
|
||||
## Copyright (c) 1998-2002 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Originally written for Apache
|
||||
##
|
||||
|
||||
namelist="$*"
|
||||
|
||||
# check whether the test command supports the -x option
|
||||
if [ -x /bin/sh ] 2>/dev/null; then
|
||||
minusx="-x"
|
||||
else
|
||||
minusx="-r"
|
||||
fi
|
||||
|
||||
# split path string
|
||||
paths="`echo $opt_p |\
|
||||
sed -e 's/^:/.:/' \
|
||||
-e 's/::/:.:/g' \
|
||||
-e 's/:$/:./' \
|
||||
-e 's/:/ /g'`"
|
||||
|
||||
# SPECIAL REQUEST
|
||||
# translate forward to reverse path
|
||||
if [ ".$opt_r" = .yes ]; then
|
||||
if [ "x$namelist" = "x." ]; then
|
||||
rp='.'
|
||||
else
|
||||
rp=''
|
||||
for pe in `IFS="$IFS/"; echo $namelist`; do
|
||||
rp="../$rp"
|
||||
done
|
||||
fi
|
||||
echo $rp | sed -e 's:/$::'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# SPECIAL REQUEST
|
||||
# strip out directory or base name
|
||||
if [ ".$opt_d" = .yes ]; then
|
||||
echo "$namelist" |\
|
||||
sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$opt_b" = .yes ]; then
|
||||
echo "$namelist" |\
|
||||
sed -e 's;.*/\([^/]*\)$;\1;'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# MAGIC SITUATION
|
||||
# Perl Interpreter (perl)
|
||||
if [ ".$opt_m" = .yes -a ".$namelist" = .perl ]; then
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
touch $tmpfile
|
||||
found=0
|
||||
pc=99
|
||||
for dir in $paths; do
|
||||
dir=`echo $dir | sed -e 's;/*$;;'`
|
||||
nc=99
|
||||
for name in perl perl5 miniperl; do
|
||||
if [ $minusx "$dir/$name" -a ! -d "$dir/$name" ]; then
|
||||
perl="$dir/$name"
|
||||
pv=`$perl -e 'printf("%.3f", $]);'`
|
||||
echo "$pv:$pc:$nc:$perl" >>$tmpfile
|
||||
found=1
|
||||
fi
|
||||
nc=`expr $nc - 1`
|
||||
done
|
||||
pc=`expr $pc - 1`
|
||||
done
|
||||
if [ $found = 1 ]; then
|
||||
perl="`cat $tmpfile | sort -r -u | sed -e 'q' | cut -d: -f4`"
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
echo "$perl"
|
||||
exit 0
|
||||
fi
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# MAGIC SITUATION
|
||||
# C pre-processor (cpp)
|
||||
if [ ".$opt_m" = .yes -a ".$namelist" = .cpp ]; then
|
||||
echo >$tmpfile.c "#include <assert.h>"
|
||||
echo >>$tmpfile.c "Syntax Error"
|
||||
# 1. try the standard cc -E approach
|
||||
cpp="${CC-cc} -E"
|
||||
(eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
|
||||
my_error=`grep -v '^ *+' $tmpfile.out`
|
||||
if [ ".$my_error" != . ]; then
|
||||
# 2. try the cc -E approach and GCC's -traditional-ccp option
|
||||
cpp="${CC-cc} -E -traditional-cpp"
|
||||
(eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
|
||||
my_error=`grep -v '^ *+' $tmpfile.out`
|
||||
if [ ".$my_error" != . ]; then
|
||||
# 3. try a standalone cpp command in path and lib dirs
|
||||
for path in $paths /lib /usr/lib /usr/local/lib; do
|
||||
path=`echo $path | sed -e 's;/*$;;'`
|
||||
if [ $minusx "$path/cpp" -a ! -d "$path/cpp" ]; then
|
||||
cpp="$path/cpp"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ".$cpp" != . ]; then
|
||||
(eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out
|
||||
my_error=`grep -v '^ *+' $tmpfile.out`
|
||||
if [ ".$my_error" != . ]; then
|
||||
# ok, we gave up...
|
||||
cpp=''
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
rm -f $tmpfile >/dev/null 2>&1
|
||||
rm -f $tmpfile.c $tmpfile.out >/dev/null 2>&1
|
||||
if [ ".$cpp" != . ]; then
|
||||
echo "$cpp"
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# STANDARD SITUATION
|
||||
# iterate over names
|
||||
for name in $namelist; do
|
||||
# iterate over paths
|
||||
for path in $paths; do
|
||||
path=`echo $path | sed -e 's;/*$;;'`
|
||||
if [ $minusx "$path/$name" -a ! -d "$path/$name" ]; then
|
||||
if [ ".$opt_s" != .yes ]; then
|
||||
echo "$path/$name"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#! /bin/sh
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# cwd must be top_srcdir
|
||||
test -f build/sysv_makefile || exit 2
|
||||
|
||||
test -f bsd_converted || exit 1
|
||||
|
||||
tmpfile=`mktemp /tmp/sysv_makefile.XXXXXX` || tmpfile="tmp.$$"
|
||||
for i in build/*.mk; do
|
||||
sed 's/^\.include "\(.*\)"/include \1/' $i >$tmpfile \
|
||||
&& cp $tmpfile $i
|
||||
done
|
||||
rm -f $tmpfile
|
||||
|
||||
rm bsd_converted
|
||||
exit 0
|
||||
@@ -1,64 +1,36 @@
|
||||
#!/bin/sh
|
||||
# $Id$
|
||||
|
||||
eval `grep '^EXTRA_VERSION=' configure.in`
|
||||
case "$EXTRA_VERSION" in
|
||||
*-dev)
|
||||
dev=1
|
||||
;;
|
||||
*)
|
||||
dev=0
|
||||
;;
|
||||
esac
|
||||
supplied_flag=$1
|
||||
|
||||
devok=0
|
||||
|
||||
while test $# -gt 0; do
|
||||
if test "$1" = "--copy"; then
|
||||
automake_flags=--copy
|
||||
fi
|
||||
|
||||
if test "$1" = "--force"; then
|
||||
devok=1
|
||||
echo "Forcing buildconf"
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
if test "$dev" = "0" -a "$devok" = "0"; then
|
||||
echo "You should not run buildconf in a release package."
|
||||
echo "use buildconf --force to override this check."
|
||||
exit 1
|
||||
if test "$supplied_flag" = "--copy"; then
|
||||
automake_flags=--copy
|
||||
fi
|
||||
|
||||
if test -z "$ZENDDIR"; then
|
||||
if grep "PHP_MAJOR_VERSION 5" main/php_version.h >/dev/null; then
|
||||
v=5
|
||||
else
|
||||
v=4
|
||||
fi
|
||||
|
||||
if test "$v" = "5"; then
|
||||
if test -r "Zend/OBJECTS2_HOWTO"; then
|
||||
:
|
||||
else
|
||||
mv Zend ZendEngine1 2>/dev/null
|
||||
mv ZendEngine2 Zend
|
||||
fi
|
||||
else
|
||||
if test -r "Zend/zend_execute_globals.h"; then
|
||||
:
|
||||
else
|
||||
mv Zend ZendEngine2 2>/dev/null
|
||||
mv ZendEngine1 Zend
|
||||
fi
|
||||
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
|
||||
|
||||
ZENDDIR=Zend
|
||||
echo "using default Zend directory"
|
||||
if test "$supplied_flag" = "--local"; then
|
||||
subdirs='SUBDIRS='
|
||||
else
|
||||
subdirs=''
|
||||
fi
|
||||
|
||||
|
||||
rm -f generated_lists
|
||||
|
||||
${MAKE:-make} -s -f build/build.mk AMFLAGS="$automake_flags" ZENDDIR="$ZENDDIR"
|
||||
case "`uname`" in
|
||||
*BSD/OS*)
|
||||
./build/bsd_makefile;;
|
||||
esac
|
||||
|
||||
${MAKE:-make} -s -f build/build.mk AMFLAGS="$automake_flags"
|
||||
Vendored
+94
-149
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2002-10-21'
|
||||
timestamp='2001-11-08'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,7 @@ timestamp='2002-10-21'
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Per Bothner <per@bothner.com>.
|
||||
# Originally written by Per Bothner <bothner@cygnus.com>.
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted ChangeLog entry.
|
||||
#
|
||||
@@ -88,40 +88,30 @@ if test $# != 0; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap 'exit 1' 1 2 15
|
||||
|
||||
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
|
||||
# compiler to aid in system detection is discouraged as it requires
|
||||
# temporary files to be created and, as you can see below, it is a
|
||||
# headache to deal with in a portable fashion.
|
||||
dummy=dummy-$$
|
||||
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
|
||||
|
||||
# CC_FOR_BUILD -- compiler used by this script.
|
||||
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
|
||||
# use `HOST_CC' if defined, but it is deprecated.
|
||||
|
||||
# This shell variable is my proudest work .. or something. --bje
|
||||
|
||||
set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ;
|
||||
(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old)
|
||||
|| (echo "$me: cannot create $tmpdir" >&2 && exit 1) ;
|
||||
dummy=$tmpdir/dummy ;
|
||||
files="$dummy.c $dummy.o $dummy.rel $dummy" ;
|
||||
trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ;
|
||||
case $CC_FOR_BUILD,$HOST_CC,$CC in
|
||||
,,) echo "int x;" > $dummy.c ;
|
||||
for c in cc gcc c89 c99 ; do
|
||||
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
|
||||
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
|
||||
,,) echo "int dummy(){}" > $dummy.c ;
|
||||
for c in cc gcc c89 ; do
|
||||
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
|
||||
if test $? = 0 ; then
|
||||
CC_FOR_BUILD="$c"; break ;
|
||||
fi ;
|
||||
done ;
|
||||
rm -f $files ;
|
||||
rm -f $dummy.c $dummy.o $dummy.rel ;
|
||||
if test x"$CC_FOR_BUILD" = x ; then
|
||||
CC_FOR_BUILD=no_compiler_found ;
|
||||
fi
|
||||
;;
|
||||
,,*) CC_FOR_BUILD=$CC ;;
|
||||
,*,*) CC_FOR_BUILD=$HOST_CC ;;
|
||||
esac ;
|
||||
unset files'
|
||||
esac'
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 1994-08-24)
|
||||
@@ -145,23 +135,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# object file format. This provides both forward
|
||||
# compatibility and a consistent mechanism for selecting the
|
||||
# object file format.
|
||||
#
|
||||
# Note: NetBSD doesn't particularly care about the vendor
|
||||
# portion of the name. We always set it to "unknown".
|
||||
sysctl="sysctl -n hw.machine_arch"
|
||||
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
|
||||
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
|
||||
case "${UNAME_MACHINE_ARCH}" in
|
||||
armeb) machine=armeb-unknown ;;
|
||||
arm*) machine=arm-unknown ;;
|
||||
sh3el) machine=shl-unknown ;;
|
||||
sh3eb) machine=sh-unknown ;;
|
||||
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
|
||||
# Determine the machine/vendor (is the vendor relevant).
|
||||
case "${UNAME_MACHINE}" in
|
||||
amiga) machine=m68k-unknown ;;
|
||||
arm32) machine=arm-unknown ;;
|
||||
atari*) machine=m68k-atari ;;
|
||||
sun3*) machine=m68k-sun ;;
|
||||
mac68k) machine=m68k-apple ;;
|
||||
macppc) machine=powerpc-apple ;;
|
||||
hp3[0-9][05]) machine=m68k-hp ;;
|
||||
ibmrt|romp-ibm) machine=romp-ibm ;;
|
||||
sparc*) machine=`uname -p`-unknown ;;
|
||||
*) machine=${UNAME_MACHINE}-unknown ;;
|
||||
esac
|
||||
# The Operating System including object format, if it has switched
|
||||
# to ELF recently, or will in the future.
|
||||
case "${UNAME_MACHINE_ARCH}" in
|
||||
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
|
||||
case "${UNAME_MACHINE}" in
|
||||
i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
|
||||
eval $set_cc_for_build
|
||||
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep __ELF__ >/dev/null
|
||||
@@ -231,7 +221,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
eval $set_cc_for_build
|
||||
cat <<EOF >$dummy.s
|
||||
.data
|
||||
\$Lformat:
|
||||
@@ -257,9 +246,10 @@ main:
|
||||
jsr \$26,exit
|
||||
.end main
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
|
||||
eval $set_cc_for_build
|
||||
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
case `$dummy` in
|
||||
case `./$dummy` in
|
||||
0-0)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
@@ -281,12 +271,9 @@ EOF
|
||||
2-1307)
|
||||
UNAME_MACHINE="alphaev68"
|
||||
;;
|
||||
3-1307)
|
||||
UNAME_MACHINE="alphaev7"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f $dummy.s $dummy && rmdir $tmpdir
|
||||
rm -f $dummy.s $dummy
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
exit 0 ;;
|
||||
Alpha\ *:Windows_NT*:*)
|
||||
@@ -304,9 +291,6 @@ EOF
|
||||
*:[Aa]miga[Oo][Ss]:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-amigaos
|
||||
exit 0 ;;
|
||||
*:[Mm]orph[Oo][Ss]:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-morphos
|
||||
exit 0 ;;
|
||||
*:OS/390:*:*)
|
||||
echo i370-ibm-openedition
|
||||
exit 0 ;;
|
||||
@@ -327,10 +311,6 @@ EOF
|
||||
NILE*:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
DRS?6000:UNIX_SV:4.2*:7*)
|
||||
case `/usr/bin/uname -p` in
|
||||
sparc) echo sparc-icl-nx7 && exit 0 ;;
|
||||
esac ;;
|
||||
sun4H:SunOS:5.*:*)
|
||||
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
@@ -359,7 +339,7 @@ EOF
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun*:*:4.2BSD:*)
|
||||
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
|
||||
case "`/bin/arch`" in
|
||||
sun3)
|
||||
@@ -437,21 +417,15 @@ EOF
|
||||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c \
|
||||
&& $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy \
|
||||
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Motorola:PowerMAX_OS:*:*)
|
||||
echo powerpc-motorola-powermax
|
||||
exit 0 ;;
|
||||
Motorola:*:4.3:PL8-*)
|
||||
echo powerpc-harris-powermax
|
||||
exit 0 ;;
|
||||
Night_Hawk:*:*:PowerMAX_OS)
|
||||
echo powerpc-harris-powermax
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
@@ -524,8 +498,8 @@ EOF
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
@@ -534,7 +508,7 @@ EOF
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:AIX:*:[45])
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
|
||||
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
@@ -623,9 +597,9 @@ EOF
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
|
||||
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`
|
||||
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
rm -f $dummy.c $dummy
|
||||
fi ;;
|
||||
esac
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
@@ -661,8 +635,8 @@ EOF
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
@@ -708,6 +682,9 @@ EOF
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
CRAY*X-MP:*:*:*)
|
||||
echo xmp-cray-unicos
|
||||
exit 0 ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
@@ -729,6 +706,9 @@ EOF
|
||||
CRAY*SV1:*:*:*)
|
||||
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
CRAY-2:*:*:*)
|
||||
echo cray2-cray-unicos
|
||||
exit 0 ;;
|
||||
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
|
||||
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
@@ -745,19 +725,7 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
# Determine whether the default compiler uses glibc.
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#include <features.h>
|
||||
#if __GLIBC__ >= 2
|
||||
LIBC=gnu
|
||||
#else
|
||||
LIBC=
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
@@ -768,9 +736,6 @@ EOF
|
||||
i*:PW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit 0 ;;
|
||||
x86:Interix*:3*)
|
||||
echo i386-pc-interix3
|
||||
exit 0 ;;
|
||||
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
|
||||
@@ -796,30 +761,16 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
ia64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
echo ${UNAME_MACHINE}-unknown-linux
|
||||
exit 0 ;;
|
||||
m68*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
mips:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef mips
|
||||
#undef mipsel
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=mipsel
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=mips
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
|
||||
case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in
|
||||
big) echo mips-unknown-linux-gnu && exit 0 ;;
|
||||
little) echo mipsel-unknown-linux-gnu && exit 0 ;;
|
||||
esac
|
||||
;;
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-gnu
|
||||
@@ -868,8 +819,7 @@ EOF
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us. cd to the root directory to prevent
|
||||
# problems with other programs or directories called `ld' in the path.
|
||||
# Set LC_ALL=C to ensure ld outputs messages in English.
|
||||
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
|
||||
ld_supported_targets=`cd /; ld --help 2>&1 \
|
||||
| sed -ne '/supported targets:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported targets: *//
|
||||
@@ -881,7 +831,7 @@ EOF
|
||||
;;
|
||||
a.out-i386-linux)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
|
||||
exit 0 ;;
|
||||
exit 0 ;;
|
||||
coff-i386)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
|
||||
exit 0 ;;
|
||||
@@ -893,29 +843,32 @@ EOF
|
||||
esac
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#include <features.h>
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
LIBC=gnu
|
||||
# else
|
||||
LIBC=gnulibc1
|
||||
# endif
|
||||
# else
|
||||
LIBC=gnulibc1
|
||||
# endif
|
||||
#else
|
||||
#ifdef __INTEL_COMPILER
|
||||
LIBC=gnu
|
||||
#else
|
||||
LIBC=gnuaout
|
||||
#endif
|
||||
#endif
|
||||
cat >$dummy.c <<EOF
|
||||
#include <features.h>
|
||||
#ifdef __cplusplus
|
||||
#include <stdio.h> /* for printf() prototype */
|
||||
int main (int argc, char *argv[]) {
|
||||
#else
|
||||
int main (argc, argv) int argc; char *argv[]; {
|
||||
#endif
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
printf ("%s-pc-linux-gnu\n", argv[1]);
|
||||
# else
|
||||
printf ("%s-pc-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
# else
|
||||
printf ("%s-pc-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
#else
|
||||
printf ("%s-pc-linux-gnuaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
|
||||
;;
|
||||
i*86:DYNIX/ptx:4*:*)
|
||||
@@ -953,13 +906,13 @@ EOF
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
|
||||
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
|
||||
&& UNAME_MACHINE=i686
|
||||
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
|
||||
&& UNAME_MACHINE=i686
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
@@ -992,12 +945,9 @@ EOF
|
||||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
mc68k:UNIX:SYSTEM5:3.51m)
|
||||
echo m68k-convergent-sysv
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
|
||||
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
@@ -1088,9 +1038,6 @@ EOF
|
||||
SX-5:SUPER-UX:*:*)
|
||||
echo sx5-nec-superux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SX-6:SUPER-UX:*:*)
|
||||
echo sx6-nec-superux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Power*:Rhapsody:*:*)
|
||||
echo powerpc-apple-rhapsody${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@@ -1101,17 +1048,15 @@ EOF
|
||||
echo `uname -p`-apple-darwin${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:procnto*:*:* | *:QNX:[0123456789]*:*)
|
||||
UNAME_PROCESSOR=`uname -p`
|
||||
if test "$UNAME_PROCESSOR" = "x86"; then
|
||||
UNAME_PROCESSOR=i386
|
||||
if test "${UNAME_MACHINE}" = "x86pc"; then
|
||||
UNAME_MACHINE=pc
|
||||
fi
|
||||
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
|
||||
echo `uname -p`-${UNAME_MACHINE}-nto-qnx
|
||||
exit 0 ;;
|
||||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit 0 ;;
|
||||
NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
|
||||
NSR-[KW]:NONSTOP_KERNEL:*:*)
|
||||
echo nsr-tandem-nsk${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:NonStop-UX:*:*)
|
||||
@@ -1283,8 +1228,8 @@ main ()
|
||||
}
|
||||
EOF
|
||||
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
|
||||
Vendored
+89
-142
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2002-09-05'
|
||||
timestamp='2001-11-08'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@@ -118,7 +118,7 @@ esac
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | freebsd*-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*)
|
||||
nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
@@ -227,42 +227,31 @@ case $basic_machine in
|
||||
1750a | 580 \
|
||||
| a29k \
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
|
||||
| clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| fr30 | frv \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dsp16xx \
|
||||
| fr30 \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| ip2k \
|
||||
| m32r | m68000 | m68k | m88k | mcore \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
| mips64vr | mips64vrel \
|
||||
| mips64orion | mips64orionel \
|
||||
| mips64vr4100 | mips64vr4100el \
|
||||
| mips64vr4300 | mips64vr4300el \
|
||||
| mips64vr5000 | mips64vr5000el \
|
||||
| mipsisa32 | mipsisa32el \
|
||||
| mipsisa64 | mipsisa64el \
|
||||
| mipsisa64sb1 | mipsisa64sb1el \
|
||||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mips16 | mips64 | mips64el | mips64orion | mips64orionel \
|
||||
| mips64vr4100 | mips64vr4100el | mips64vr4300 \
|
||||
| mips64vr4300el | mips64vr5000 | mips64vr5000el \
|
||||
| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
|
||||
| mipsisa32 \
|
||||
| mn10200 | mn10300 \
|
||||
| ns16k | ns32k \
|
||||
| openrisc | or32 \
|
||||
| openrisc \
|
||||
| pdp10 | pdp11 | pj | pjl \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
|
||||
| pyramid \
|
||||
| sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
|
||||
| sh | sh[34] | sh[34]eb | shbe | shle \
|
||||
| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
|
||||
| strongarm \
|
||||
| tahoe | thumb | tic80 | tron \
|
||||
| v850 | v850e \
|
||||
| v850 \
|
||||
| we32k \
|
||||
| x86 | xscale | xstormy16 | xtensa \
|
||||
| x86 | xscale | xstormy16 \
|
||||
| z8k)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
@@ -289,51 +278,38 @@ case $basic_machine in
|
||||
580-* \
|
||||
| a29k-* \
|
||||
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
|
||||
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
|
||||
| alphapca5[67]-* | arc-* \
|
||||
| arm-* | armbe-* | armle-* | armv*-* \
|
||||
| avr-* \
|
||||
| bs2000-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \
|
||||
| clipper-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c54x-* \
|
||||
| clipper-* | cray2-* | cydra-* \
|
||||
| d10v-* | d30v-* \
|
||||
| elxsi-* \
|
||||
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
|
||||
| f30[01]-* | f700-* | fr30-* | fx80-* \
|
||||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
| ip2k-* \
|
||||
| m32r-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | mcore-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
| mips16-* \
|
||||
| mips64-* | mips64el-* \
|
||||
| mips64vr-* | mips64vrel-* \
|
||||
| mips64orion-* | mips64orionel-* \
|
||||
| mips64vr4100-* | mips64vr4100el-* \
|
||||
| mips64vr4300-* | mips64vr4300el-* \
|
||||
| mips64vr5000-* | mips64vr5000el-* \
|
||||
| mipsisa32-* | mipsisa32el-* \
|
||||
| mipsisa64-* | mipsisa64el-* \
|
||||
| mipsisa64sb1-* | mipsisa64sb1el-* \
|
||||
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
|
||||
| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
|
||||
| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
|
||||
| mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
|
||||
| none-* | np1-* | ns16k-* | ns32k-* \
|
||||
| orion-* \
|
||||
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
|
||||
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
|
||||
| pyramid-* \
|
||||
| romp-* | rs6000-* \
|
||||
| sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
|
||||
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
|
||||
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
|
||||
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
|
||||
| tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \
|
||||
| v850-* | v850e-* | vax-* \
|
||||
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \
|
||||
| sparc-* | sparc64-* | sparc86x-* | sparclite-* \
|
||||
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \
|
||||
| t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
|
||||
| v850-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
|
||||
| xtensa-* \
|
||||
| x86-* | x86_64-* | xmp-* | xps100-* | xscale-* | xstormy16-* \
|
||||
| ymp-* \
|
||||
| z8k-*)
|
||||
;;
|
||||
@@ -398,10 +374,6 @@ case $basic_machine in
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
c90)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
os=-bsd
|
||||
@@ -422,8 +394,16 @@ case $basic_machine in
|
||||
basic_machine=c38-convex
|
||||
os=-bsd
|
||||
;;
|
||||
cray | j90)
|
||||
basic_machine=j90-cray
|
||||
cray | ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
cray2)
|
||||
basic_machine=cray2-cray
|
||||
os=-unicos
|
||||
;;
|
||||
[cjt]90)
|
||||
basic_machine=${basic_machine}-cray
|
||||
os=-unicos
|
||||
;;
|
||||
crds | unos)
|
||||
@@ -438,14 +418,6 @@ case $basic_machine in
|
||||
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
|
||||
basic_machine=mips-dec
|
||||
;;
|
||||
decsystem10* | dec10*)
|
||||
basic_machine=pdp10-dec
|
||||
os=-tops10
|
||||
;;
|
||||
decsystem20* | dec20*)
|
||||
basic_machine=pdp10-dec
|
||||
os=-tops20
|
||||
;;
|
||||
delta | 3300 | motorola-3300 | motorola-delta \
|
||||
| 3300-motorola | delta-motorola)
|
||||
basic_machine=m68k-motorola
|
||||
@@ -626,6 +598,14 @@ case $basic_machine in
|
||||
basic_machine=m68k-atari
|
||||
os=-mint
|
||||
;;
|
||||
mipsel*-linux*)
|
||||
basic_machine=mipsel-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips*-linux*)
|
||||
basic_machine=mips-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
@@ -640,10 +620,6 @@ case $basic_machine in
|
||||
basic_machine=m68k-rom68k
|
||||
os=-coff
|
||||
;;
|
||||
morphos)
|
||||
basic_machine=powerpc-unknown
|
||||
os=-morphos
|
||||
;;
|
||||
msdos)
|
||||
basic_machine=i386-pc
|
||||
os=-msdos
|
||||
@@ -723,10 +699,6 @@ case $basic_machine in
|
||||
basic_machine=hppa1.1-oki
|
||||
os=-proelf
|
||||
;;
|
||||
or32 | or32-*)
|
||||
basic_machine=or32-unknown
|
||||
os=-coff
|
||||
;;
|
||||
OSE68000 | ose68000)
|
||||
basic_machine=m68000-ericsson
|
||||
os=-ose
|
||||
@@ -749,13 +721,13 @@ case $basic_machine in
|
||||
pbb)
|
||||
basic_machine=m68k-tti
|
||||
;;
|
||||
pc532 | pc532-*)
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pentium | p5 | k5 | k6 | nexgen | viac3)
|
||||
basic_machine=i586-pc
|
||||
;;
|
||||
pentiumpro | p6 | 6x86 | athlon | athlon_*)
|
||||
pentiumpro | p6 | 6x86 | athlon)
|
||||
basic_machine=i686-pc
|
||||
;;
|
||||
pentiumii | pentium2)
|
||||
@@ -776,22 +748,22 @@ case $basic_machine in
|
||||
power) basic_machine=power-ibm
|
||||
;;
|
||||
ppc) basic_machine=powerpc-unknown
|
||||
;;
|
||||
;;
|
||||
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
basic_machine=powerpcle-unknown
|
||||
;;
|
||||
;;
|
||||
ppcle-* | powerpclittle-*)
|
||||
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppc64) basic_machine=powerpc64-unknown
|
||||
;;
|
||||
;;
|
||||
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
|
||||
basic_machine=powerpc64le-unknown
|
||||
;;
|
||||
;;
|
||||
ppc64le-* | powerpc64little-*)
|
||||
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
@@ -822,12 +794,6 @@ case $basic_machine in
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
sb1)
|
||||
basic_machine=mipsisa64sb1-unknown
|
||||
;;
|
||||
sb1el)
|
||||
basic_machine=mipsisa64sb1el-unknown
|
||||
;;
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
@@ -901,22 +867,10 @@ case $basic_machine in
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
t3d)
|
||||
basic_machine=alpha-cray
|
||||
os=-unicos
|
||||
;;
|
||||
t3e)
|
||||
basic_machine=alphaev5-cray
|
||||
basic_machine=t3e-cray
|
||||
os=-unicos
|
||||
;;
|
||||
t90)
|
||||
basic_machine=t90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
tic4x | c4x*)
|
||||
basic_machine=tic4x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tic54x | c54x*)
|
||||
basic_machine=tic54x-unknown
|
||||
os=-coff
|
||||
@@ -927,10 +881,6 @@ case $basic_machine in
|
||||
tx39el)
|
||||
basic_machine=mipstx39el-unknown
|
||||
;;
|
||||
toad1)
|
||||
basic_machine=pdp10-xkl
|
||||
os=-tops20
|
||||
;;
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
@@ -955,8 +905,8 @@ case $basic_machine in
|
||||
os=-vms
|
||||
;;
|
||||
vpp*|vx|vx-*)
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
vxworks960)
|
||||
basic_machine=i960-wrs
|
||||
os=-vxworks
|
||||
@@ -981,13 +931,13 @@ case $basic_machine in
|
||||
basic_machine=i386-pc
|
||||
os=-windows32-msvcrt
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
ymp)
|
||||
basic_machine=ymp-cray
|
||||
xmp)
|
||||
basic_machine=xmp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
z8k-*-coff)
|
||||
basic_machine=z8k-unknown
|
||||
os=-sim
|
||||
@@ -1008,6 +958,13 @@ case $basic_machine in
|
||||
op60c)
|
||||
basic_machine=hppa1.1-oki
|
||||
;;
|
||||
mips)
|
||||
if [ x$os = x-linux-gnu ]; then
|
||||
basic_machine=mips-unknown
|
||||
else
|
||||
basic_machine=mips-mips
|
||||
fi
|
||||
;;
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
@@ -1027,16 +984,13 @@ case $basic_machine in
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
|
||||
sh3 | sh4 | sh3eb | sh4eb)
|
||||
basic_machine=sh-unknown
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
sparc | sparcv9 | sparcv9b)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
cydra)
|
||||
basic_machine=cydra-cydrome
|
||||
;;
|
||||
orion)
|
||||
@@ -1051,6 +1005,10 @@ case $basic_machine in
|
||||
pmac | pmac-mpw)
|
||||
basic_machine=powerpc-apple
|
||||
;;
|
||||
c4x*)
|
||||
basic_machine=c4x-none
|
||||
os=-coff
|
||||
;;
|
||||
*-unknown)
|
||||
# Make sure to match an already-canonicalized machine name.
|
||||
;;
|
||||
@@ -1116,8 +1074,7 @@ case $os in
|
||||
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* | -powermax*)
|
||||
| -os2* | -vos* | -palmos* | -uclinux*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@@ -1169,20 +1126,14 @@ case $os in
|
||||
-acis*)
|
||||
os=-aos
|
||||
;;
|
||||
-atheos*)
|
||||
os=-atheos
|
||||
;;
|
||||
-386bsd)
|
||||
os=-bsd
|
||||
;;
|
||||
-ctix* | -uts*)
|
||||
os=-sysv
|
||||
;;
|
||||
-nova*)
|
||||
os=-rtmk-nova
|
||||
;;
|
||||
-ns2 )
|
||||
os=-nextstep2
|
||||
os=-nextstep2
|
||||
;;
|
||||
-nsk*)
|
||||
os=-nsk
|
||||
@@ -1221,8 +1172,8 @@ case $os in
|
||||
-xenix)
|
||||
os=-xenix
|
||||
;;
|
||||
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
|
||||
os=-mint
|
||||
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
|
||||
os=-mint
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
@@ -1255,11 +1206,10 @@ case $basic_machine in
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
# This must come before the *-dec entry.
|
||||
pdp10-*)
|
||||
os=-tops20
|
||||
;;
|
||||
pdp11-*)
|
||||
pdp11-*)
|
||||
os=-none
|
||||
;;
|
||||
*-dec | vax-*)
|
||||
@@ -1286,9 +1236,6 @@ case $basic_machine in
|
||||
mips*-*)
|
||||
os=-elf
|
||||
;;
|
||||
or32-*)
|
||||
os=-coff
|
||||
;;
|
||||
*-tti) # must be before sparc entry or we get the wrong os.
|
||||
os=-sysv3
|
||||
;;
|
||||
@@ -1352,19 +1299,19 @@ case $basic_machine in
|
||||
*-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
*-gould)
|
||||
*-gould)
|
||||
os=-sysv
|
||||
;;
|
||||
*-highlevel)
|
||||
*-highlevel)
|
||||
os=-bsd
|
||||
;;
|
||||
*-encore)
|
||||
os=-bsd
|
||||
;;
|
||||
*-sgi)
|
||||
*-sgi)
|
||||
os=-irix
|
||||
;;
|
||||
*-siemens)
|
||||
*-siemens)
|
||||
os=-sysv4
|
||||
;;
|
||||
*-masscomp)
|
||||
@@ -1436,7 +1383,7 @@ case $basic_machine in
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-vxsim* | -vxworks* | -windiss*)
|
||||
-vxsim* | -vxworks*)
|
||||
vendor=wrs
|
||||
;;
|
||||
-aux*)
|
||||
|
||||
+295
-378
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,88 @@
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 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. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
|
||||
|
||||
AC_DEFUN(LIB_SHARED_CONVENIENCE,[
|
||||
lib_target="\$(LTLIBRARY_NAME)"
|
||||
cat >>$1<<EOF
|
||||
\$(LTLIBRARY_NAME): \$(LTLIBRARY_SHARED_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
|
||||
\$(SHARED_LIBTOOL) --mode=link \$(COMPILE) \$(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 \$(CC) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(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
|
||||
if test "$BSD_MAKEFILE" = "yes"; then
|
||||
lib_include_conf=".include \"\$(top_builddir)/config_vars.mk\""
|
||||
else
|
||||
lib_include_conf="include \$(top_builddir)/config_vars.mk"
|
||||
fi
|
||||
cat >$lib_makefile<<EOF
|
||||
$lib_include_conf
|
||||
LTLIBRARY_OBJECTS = \$(LTLIBRARY_SOURCES:.c=.lo) \$(LTLIBRARY_OBJECTS_X)
|
||||
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
|
||||
])
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
SUBDIRS = $(EXT_SUBDIRS)
|
||||
|
||||
include $(top_srcdir)/build/rules.mk
|
||||
@@ -0,0 +1,2 @@
|
||||
aspell
|
||||
Rasmus Lerdorf
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
LTLIBRARY_NAME = libaspell.la
|
||||
LTLIBRARY_SOURCES = aspell.c
|
||||
|
||||
include $(top_srcdir)/build/dynlib.mk
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Rasmus Lerdorf <rasmus@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#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"
|
||||
|
||||
/* {{{ aspell_functions[]
|
||||
*/
|
||||
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 = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"aspell", aspell_functions, PHP_MINIT(aspell), NULL, NULL, NULL, PHP_MINFO(aspell), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_ASPELL
|
||||
ZEND_GET_MODULE(aspell)
|
||||
#endif
|
||||
|
||||
/* {{{ php_aspell_close
|
||||
*/
|
||||
static void php_aspell_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
aspell *sc = (aspell *)rsrc->ptr;
|
||||
|
||||
aspell_free(sc);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION
|
||||
*/
|
||||
PHP_MINIT_FUNCTION(aspell)
|
||||
{
|
||||
le_aspell = zend_register_list_destructors_ex(php_aspell_close, NULL, "aspell", module_number);
|
||||
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(Z_STRVAL_PP(master), Z_STRVAL_PP(personal));
|
||||
}
|
||||
else
|
||||
sc=aspell_new(Z_STRVAL_PP(master), "");
|
||||
|
||||
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(Z_LVAL_PP(scin), &type);
|
||||
if(!sc)
|
||||
{
|
||||
php_error(E_WARNING, "%d is not an ASPELL result index", Z_LVAL_PP(scin));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
sug = aspell_suggest(sc, Z_STRVAL_PP(word));
|
||||
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(Z_LVAL_PP(scin), &type);
|
||||
if(!sc)
|
||||
{
|
||||
php_error(E_WARNING, "%d is not an ASPELL result index", Z_LVAL_PP(scin));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (aspell_check(sc, Z_STRVAL_PP(word)))
|
||||
{
|
||||
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(Z_LVAL_PP(scin), &type);
|
||||
if(!sc)
|
||||
{
|
||||
php_error(E_WARNING, "%d is not an ASPELL result index", Z_LVAL_PP(scin));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (aspell_check_raw(sc, Z_STRVAL_PP(word)))
|
||||
{
|
||||
RETURN_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINFO_FUNCTION
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(aspell)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "ASpell Support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -0,0 +1,30 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
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
|
||||
|
||||
PHP_ADD_INCLUDE($ASPELL_DIR/include)
|
||||
PHP_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_RESULT(no)
|
||||
fi
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2001 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -12,19 +12,30 @@
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Rui Hirokawa <hirokawa@php.net> |
|
||||
| Author: Rasmus Lerdorf <rasmus@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef MBFL_MBFILTER_TW_H
|
||||
#define MBFL_MBFILTER_TW_H
|
||||
#ifndef PHP_ASPELL_H
|
||||
#define PHP_ASPELL_H
|
||||
#if HAVE_ASPELL
|
||||
extern zend_module_entry aspell_module_entry;
|
||||
#define aspell_module_ptr &aspell_module_entry
|
||||
|
||||
int mbfl_filt_conv_euctw_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC);
|
||||
int mbfl_filt_conv_wchar_euctw(int c, mbfl_convert_filter *filter TSRMLS_DC);
|
||||
int mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC);
|
||||
int mbfl_filt_conv_wchar_big5(int c, mbfl_convert_filter *filter TSRMLS_DC);
|
||||
PHP_MINIT_FUNCTION(aspell);
|
||||
PHP_MINFO_FUNCTION(aspell);
|
||||
|
||||
#endif /* MBFL_MBFILTER_TW_H */
|
||||
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 /* PHP_ASPELL_H */
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
LTLIBRARY_NAME = libbcmath.la
|
||||
LTLIBRARY_SOURCES = bcmath.c number.c
|
||||
LTLIBRARY_SHARED_NAME = bcmath.la
|
||||
LTLIBRARY_DEPENDENCIES = libbcmath/libbcmath.la
|
||||
LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES)
|
||||
LTLIBRARY_SHARED_LIBADD = $(LTLIBRARY_LIBADD)
|
||||
|
||||
SUBDIRS = libbcmath
|
||||
|
||||
include $(top_srcdir)/build/dynlib.mk
|
||||
+102
-107
@@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -28,9 +28,7 @@
|
||||
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_bcmath.h"
|
||||
#include "libbcmath/src/bcmath.h"
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(bcmath);
|
||||
#include "ext/bcmath/libbcmath/src/bcmath.h"
|
||||
|
||||
function_entry bcmath_functions[] = {
|
||||
PHP_FE(bcadd, NULL)
|
||||
@@ -49,14 +47,10 @@ zend_module_entry bcmath_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"bcmath",
|
||||
bcmath_functions,
|
||||
#if ZTS
|
||||
PHP_MODULE_STARTUP_N(bcmath),
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
NULL,
|
||||
PHP_MINIT(bcmath),
|
||||
PHP_MSHUTDOWN(bcmath),
|
||||
PHP_RINIT(bcmath),
|
||||
PHP_RSHUTDOWN(bcmath),
|
||||
NULL,
|
||||
PHP_MINFO(bcmath),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
@@ -70,23 +64,55 @@ ZEND_GET_MODULE(bcmath)
|
||||
static long bc_precision;
|
||||
#endif
|
||||
|
||||
#if ZTS
|
||||
PHP_MODULE_STARTUP_D(bcmath)
|
||||
/* Storage used for special numbers. */
|
||||
bc_num _zero_;
|
||||
bc_num _one_;
|
||||
bc_num _two_;
|
||||
|
||||
|
||||
/* Make a copy of a number! Just increments the reference count! */
|
||||
bc_num copy_num (bc_num num)
|
||||
{
|
||||
zend_bcmath_globals *bcmath_globals;
|
||||
num->n_refs++;
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize a number NUM by making it a copy of zero. */
|
||||
void init_num (bc_num *num)
|
||||
{
|
||||
*num = copy_num (_zero_);
|
||||
}
|
||||
|
||||
|
||||
PHP_MINIT_FUNCTION(bcmath)
|
||||
{
|
||||
extern bc_num _zero_;
|
||||
extern bc_num _one_;
|
||||
extern bc_num _two_;
|
||||
|
||||
_zero_ = bc_new_num (1, 0);
|
||||
_one_ = bc_new_num (1, 0);
|
||||
_one_->n_value[0] = 1;
|
||||
_two_ = bc_new_num (1, 0);
|
||||
_two_->n_value[0] = 2;
|
||||
persist_alloc(_zero_);
|
||||
persist_alloc(_one_);
|
||||
persist_alloc(_two_);
|
||||
persist_alloc(_zero_->n_ptr);
|
||||
persist_alloc(_one_->n_ptr);
|
||||
persist_alloc(_two_->n_ptr);
|
||||
|
||||
ts_allocate_id(&bcmath_globals_id, sizeof(zend_bcmath_globals), NULL, NULL);
|
||||
bcmath_globals = ts_resource(bcmath_globals_id);
|
||||
return SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
PHP_RSHUTDOWN_FUNCTION(bcmath)
|
||||
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(bcmath)
|
||||
{
|
||||
bc_free_num(&BCG(_zero_));
|
||||
bc_free_num(&BCG(_one_));
|
||||
bc_free_num(&BCG(_two_));
|
||||
|
||||
bc_free_num(&_zero_);
|
||||
bc_free_num(&_one_);
|
||||
bc_free_num(&_two_);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -96,9 +122,6 @@ PHP_RINIT_FUNCTION(bcmath)
|
||||
if (cfg_get_long("bcmath.scale", &bc_precision)==FAILURE) {
|
||||
bc_precision=0;
|
||||
}
|
||||
if(bc_precision<0) bc_precision=0;
|
||||
bc_init_numbers(TSRMLS_C);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -110,21 +133,6 @@ PHP_MINFO_FUNCTION(bcmath)
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
/* {{{ php_str2num
|
||||
Convert to bc_num detecting scale */
|
||||
static void php_str2num(bc_num *num, char *str TSRMLS_DC)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!(p = strchr(str, '.'))) {
|
||||
bc_str2num(num, str, 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
bc_str2num(num, str, strlen(p+1) TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
|
||||
Returns the sum of two arbitrary precision numbers */
|
||||
PHP_FUNCTION(bcadd)
|
||||
@@ -144,7 +152,7 @@ PHP_FUNCTION(bcadd)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -152,14 +160,12 @@ PHP_FUNCTION(bcadd)
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
|
||||
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale);
|
||||
bc_add (first, second, &result, scale);
|
||||
if (result->n_scale > scale)
|
||||
result->n_scale = scale;
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
@@ -189,7 +195,7 @@ PHP_FUNCTION(bcsub)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -197,14 +203,12 @@ PHP_FUNCTION(bcsub)
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
|
||||
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale);
|
||||
bc_sub (first, second, &result, scale);
|
||||
if (result->n_scale > scale)
|
||||
result->n_scale = scale;
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
@@ -234,7 +238,7 @@ PHP_FUNCTION(bcmul)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -242,14 +246,12 @@ PHP_FUNCTION(bcmul)
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
|
||||
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
|
||||
bc_multiply (first, second, &result, scale TSRMLS_CC);
|
||||
if (result->n_scale > scale)
|
||||
result->n_scale = scale;
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale);
|
||||
bc_multiply (first, second, &result, scale);
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
@@ -279,7 +281,7 @@ PHP_FUNCTION(bcdiv)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -287,21 +289,19 @@ PHP_FUNCTION(bcdiv)
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
|
||||
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
|
||||
switch (bc_divide (first, second, &result, scale TSRMLS_CC)) {
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale);
|
||||
switch (bc_divide (first, second, &result, scale)) {
|
||||
case 0: /* OK */
|
||||
if (result->n_scale > scale)
|
||||
result->n_scale = scale;
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
break;
|
||||
case -1: /* division by zero */
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
|
||||
php_error(E_WARNING, "Division by zero");
|
||||
break;
|
||||
}
|
||||
bc_free_num(&first);
|
||||
@@ -330,19 +330,19 @@ PHP_FUNCTION(bcmod)
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), 0 TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), 0 TSRMLS_CC);
|
||||
switch (bc_modulo(first, second, &result, 0 TSRMLS_CC)) {
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), 0);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), 0);
|
||||
switch (bc_modulo(first, second, &result, 0)) {
|
||||
case 0:
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
break;
|
||||
case -1:
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
|
||||
php_error(E_WARNING, "Division by zero");
|
||||
break;
|
||||
}
|
||||
bc_free_num(&first);
|
||||
@@ -371,7 +371,7 @@ PHP_FUNCTION(bcpow)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -379,14 +379,12 @@ PHP_FUNCTION(bcpow)
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
|
||||
php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
|
||||
bc_raise (first, second, &result, scale TSRMLS_CC);
|
||||
if (result->n_scale > scale)
|
||||
result->n_scale = scale;
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale);
|
||||
bc_raise (first, second, &result, scale);
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
@@ -416,30 +414,28 @@ PHP_FUNCTION(bcsqrt)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string_ex(left);
|
||||
bc_init_num(&result TSRMLS_CC);
|
||||
php_str2num(&result, Z_STRVAL_PP(left) TSRMLS_CC);
|
||||
if (bc_sqrt (&result, scale TSRMLS_CC) != 0) {
|
||||
if (result->n_scale > scale)
|
||||
result->n_scale = scale;
|
||||
bc_init_num(&result);
|
||||
bc_str2num(&result, Z_STRVAL_PP(left), scale);
|
||||
if (bc_sqrt (&result, scale) != 0) {
|
||||
Z_STRVAL_P(return_value) = bc_num2str(result);
|
||||
Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
} else {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Square root of negative number");
|
||||
php_error(E_WARNING, "Square root of negative number");
|
||||
}
|
||||
bc_free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int bccomp(string left_operand, string right_operand [, int scale])
|
||||
/* {{{ proto string bccomp(string left_operand, string right_operand [, int scale])
|
||||
Compares two arbitrary precision numbers */
|
||||
PHP_FUNCTION(bccomp)
|
||||
{
|
||||
@@ -458,7 +454,7 @@ PHP_FUNCTION(bccomp)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long_ex(scale_param);
|
||||
scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param);
|
||||
scale = (int) Z_LVAL_PP(scale_param);
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -467,11 +463,11 @@ PHP_FUNCTION(bccomp)
|
||||
|
||||
convert_to_string_ex(left);
|
||||
convert_to_string_ex(right);
|
||||
bc_init_num(&first TSRMLS_CC);
|
||||
bc_init_num(&second TSRMLS_CC);
|
||||
bc_init_num(&first);
|
||||
bc_init_num(&second);
|
||||
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale TSRMLS_CC);
|
||||
bc_str2num(&first, Z_STRVAL_PP(left), scale);
|
||||
bc_str2num(&second, Z_STRVAL_PP(right), scale);
|
||||
Z_LVAL_P(return_value) = bc_compare(first, second);
|
||||
Z_TYPE_P(return_value) = IS_LONG;
|
||||
|
||||
@@ -481,7 +477,7 @@ PHP_FUNCTION(bccomp)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool bcscale(int scale)
|
||||
/* {{{ proto string bcscale(int scale)
|
||||
Sets default scale parameter for all bc math functions */
|
||||
PHP_FUNCTION(bcscale)
|
||||
{
|
||||
@@ -492,8 +488,7 @@ PHP_FUNCTION(bcscale)
|
||||
}
|
||||
|
||||
convert_to_long_ex(new_scale);
|
||||
bc_precision = (Z_LVAL_PP(new_scale)<0) ? 0 : Z_LVAL_PP(new_scale);
|
||||
|
||||
bc_precision = Z_LVAL_PP(new_scale);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -7,11 +7,8 @@ PHP_ARG_ENABLE(bcmath, whether to enable bc style precision math functions,
|
||||
|
||||
if test "$PHP_BCMATH" != "no"; then
|
||||
AC_DEFINE(WITH_BCMATH, 1, [Whether you have bcmath])
|
||||
PHP_NEW_EXTENSION(bcmath, bcmath.c number.c \
|
||||
libbcmath/src/add.c libbcmath/src/div.c libbcmath/src/init.c libbcmath/src/neg.c libbcmath/src/outofmem.c libbcmath/src/raisemod.c libbcmath/src/rt.c libbcmath/src/sub.c \
|
||||
libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c libbcmath/src/num2long.c libbcmath/src/output.c libbcmath/src/recmul.c \
|
||||
libbcmath/src/sqrt.c libbcmath/src/zero.c libbcmath/src/debug.c libbcmath/src/doaddsub.c libbcmath/src/nearzero.c libbcmath/src/num2str.c libbcmath/src/raise.c \
|
||||
libbcmath/src/rmzero.c libbcmath/src/str2num.c,
|
||||
$ext_shared,,-I@ext_srcdir@/libbcmath/src)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/libbcmath/src)
|
||||
PHP_EXTENSION(bcmath, $ext_shared)
|
||||
PHP_FAST_OUTPUT($ext_builddir/libbcmath/Makefile $ext_builddir/libbcmath/src/Makefile)
|
||||
LIB_BUILD($ext_builddir/libbcmath,$ext_shared,yes)
|
||||
LIB_BUILD($ext_builddir/libbcmath/src,$ext_shared,yes)
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
LTLIBRARY_NAME = libbcmath.la
|
||||
LTLIBRARY_DEPENDENCIES = src/libbcmath.la
|
||||
LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES)
|
||||
LTLIBRARY_SHARED_LIBADD = $(LTLIBRARY_LIBADD)
|
||||
|
||||
SUBDIRS = src
|
||||
|
||||
include $(top_srcdir)/build/dynlib.mk
|
||||
@@ -0,0 +1,3 @@
|
||||
# Documentation makefile
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
@@ -0,0 +1,171 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
# Documentation makefile
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
CC = @CC@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps doc/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = doc
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
mostlyclean-am: mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-generic clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -0,0 +1 @@
|
||||
./" bcmath library documentation
|
||||
@@ -0,0 +1,7 @@
|
||||
LTLIBRARY_NAME = libbcmath.la
|
||||
LTLIBRARY_SOURCES = add.c div.c init.c neg.c outofmem.c raisemod.c rt.c sub.c \
|
||||
compare.c divmod.c int2num.c num2long.c output.c recmul.c \
|
||||
sqrt.c zero.c debug.c doaddsub.c nearzero.c num2str.c raise.c \
|
||||
rmzero.c str2num.c
|
||||
|
||||
include $(top_srcdir)/build/dynlib.mk
|
||||
@@ -52,9 +52,6 @@ typedef struct bc_struct
|
||||
in the case of leading zeros generated. */
|
||||
} bc_struct;
|
||||
|
||||
#include <php.h>
|
||||
#include <ext/bcmath/php_bcmath.h>
|
||||
|
||||
|
||||
/* The base used in storing the numbers in n_value above.
|
||||
Currently this MUST be 10. */
|
||||
@@ -84,6 +81,12 @@ typedef struct bc_struct
|
||||
#endif
|
||||
|
||||
|
||||
/* Global numbers. */
|
||||
extern bc_num _zero_;
|
||||
extern bc_num _one_;
|
||||
extern bc_num _two_;
|
||||
|
||||
|
||||
/* Function Prototypes */
|
||||
|
||||
/* Define the _PROTOTYPE macro if it is needed. */
|
||||
@@ -96,7 +99,7 @@ typedef struct bc_struct
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_PROTOTYPE(void bc_init_numbers, (TSRMLS_D));
|
||||
_PROTOTYPE(void bc_init_numbers, (void));
|
||||
|
||||
_PROTOTYPE(bc_num bc_new_num, (int length, int scale));
|
||||
|
||||
@@ -104,9 +107,9 @@ _PROTOTYPE(void bc_free_num, (bc_num *num));
|
||||
|
||||
_PROTOTYPE(bc_num bc_copy_num, (bc_num num));
|
||||
|
||||
_PROTOTYPE(void bc_init_num, (bc_num *num TSRMLS_DC));
|
||||
_PROTOTYPE(void bc_init_num, (bc_num *num));
|
||||
|
||||
_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale TSRMLS_DC));
|
||||
_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale));
|
||||
|
||||
_PROTOTYPE(char *bc_num2str, (bc_num num));
|
||||
|
||||
@@ -116,7 +119,7 @@ _PROTOTYPE(long bc_num2long, (bc_num num));
|
||||
|
||||
_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2));
|
||||
|
||||
_PROTOTYPE(char bc_is_zero, (bc_num num TSRMLS_DC));
|
||||
_PROTOTYPE(char bc_is_zero, (bc_num num));
|
||||
|
||||
_PROTOTYPE(char bc_is_near_zero, (bc_num num, int scale));
|
||||
|
||||
@@ -126,26 +129,26 @@ _PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
|
||||
|
||||
_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
|
||||
|
||||
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC));
|
||||
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale));
|
||||
|
||||
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC));
|
||||
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale));
|
||||
|
||||
_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result,
|
||||
int scale TSRMLS_DC));
|
||||
int scale));
|
||||
|
||||
_PROTOTYPE(int bc_divmod, (bc_num num1, bc_num num2, bc_num *quot,
|
||||
bc_num *rem, int scale TSRMLS_DC));
|
||||
bc_num *rem, int scale));
|
||||
|
||||
_PROTOTYPE(int bc_raisemod, (bc_num base, bc_num expo, bc_num mod,
|
||||
bc_num *result, int scale TSRMLS_DC));
|
||||
bc_num *result, int scale));
|
||||
|
||||
_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result,
|
||||
int scale TSRMLS_DC));
|
||||
int scale));
|
||||
|
||||
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale TSRMLS_DC));
|
||||
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale));
|
||||
|
||||
_PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int),
|
||||
int leading_zero TSRMLS_DC));
|
||||
int leading_zero));
|
||||
|
||||
/* Prototypes needed for external utility routines. */
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#if PHP_WIN32
|
||||
#include "../../../../main/config.w32.h"
|
||||
#elif defined(NETWARE)
|
||||
#include "config.nw.h"
|
||||
#else
|
||||
#include "php_config.h"
|
||||
#endif
|
||||
|
||||
@@ -48,9 +48,10 @@ out_char (int c)
|
||||
|
||||
|
||||
void
|
||||
pn (bc_num num TSRMLS_DC)
|
||||
pn (num)
|
||||
bc_num num;
|
||||
{
|
||||
bc_out_num (num, 10, out_char, 0 TSRMLS_CC);
|
||||
bc_out_num (num, 10, out_char, 0);
|
||||
out_char ('\n');
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,9 @@ _one_mult (num, size, digit, result)
|
||||
by zero is tried. The algorithm is found in Knuth Vol 2. p237. */
|
||||
|
||||
int
|
||||
bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
|
||||
bc_divide (n1, n2, quot, scale)
|
||||
bc_num n1, n2, *quot;
|
||||
int scale;
|
||||
{
|
||||
bc_num qval;
|
||||
unsigned char *num1, *num2;
|
||||
@@ -98,7 +100,7 @@ bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
|
||||
unsigned int norm;
|
||||
|
||||
/* Test for divide by zero. */
|
||||
if (bc_is_zero (n2 TSRMLS_CC)) return -1;
|
||||
if (bc_is_zero (n2)) return -1;
|
||||
|
||||
/* Test for divide by 1. If it is we must truncate. */
|
||||
if (n2->n_scale == 0)
|
||||
@@ -259,7 +261,7 @@ bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale TSRMLS_DC)
|
||||
|
||||
/* Clean up and return the number. */
|
||||
qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
|
||||
if (bc_is_zero (qval TSRMLS_CC)) qval->n_sign = PLUS;
|
||||
if (bc_is_zero (qval)) qval->n_sign = PLUS;
|
||||
_bc_rm_leading_zeros (qval);
|
||||
bc_free_num (quot);
|
||||
*quot = qval;
|
||||
|
||||
@@ -45,24 +45,26 @@
|
||||
*/
|
||||
|
||||
int
|
||||
bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS_DC)
|
||||
bc_divmod (num1, num2, quot, rem, scale)
|
||||
bc_num num1, num2, *quot, *rem;
|
||||
int scale;
|
||||
{
|
||||
bc_num quotient = NULL;
|
||||
bc_num temp;
|
||||
int rscale;
|
||||
|
||||
/* Check for correct numbers. */
|
||||
if (bc_is_zero (num2 TSRMLS_CC)) return -1;
|
||||
if (bc_is_zero (num2)) return -1;
|
||||
|
||||
/* Calculate final scale. */
|
||||
rscale = MAX (num1->n_scale, num2->n_scale+scale);
|
||||
bc_init_num(&temp TSRMLS_CC);
|
||||
bc_init_num(&temp);
|
||||
|
||||
/* Calculate it. */
|
||||
bc_divide (num1, num2, &temp, scale TSRMLS_CC);
|
||||
bc_divide (num1, num2, &temp, scale);
|
||||
if (quot)
|
||||
quotient = bc_copy_num (temp);
|
||||
bc_multiply (temp, num2, &temp, rscale TSRMLS_CC);
|
||||
bc_multiply (temp, num2, &temp, rscale);
|
||||
bc_sub (num1, temp, rem, rscale);
|
||||
bc_free_num (&temp);
|
||||
|
||||
@@ -80,8 +82,10 @@ bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS
|
||||
result in RESULT. */
|
||||
|
||||
int
|
||||
bc_modulo (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
|
||||
bc_modulo (num1, num2, result, scale)
|
||||
bc_num num1, num2, *result;
|
||||
int scale;
|
||||
{
|
||||
return bc_divmod (num1, num2, NULL, result, scale TSRMLS_CC);
|
||||
return bc_divmod (num1, num2, NULL, result, scale);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,12 @@
|
||||
#include "bcmath.h"
|
||||
#include "private.h"
|
||||
|
||||
#ifdef SANDER_0
|
||||
/* Storage used for special numbers. */
|
||||
bc_num _zero_;
|
||||
bc_num _one_;
|
||||
bc_num _two_;
|
||||
|
||||
bc_num _bc_Free_list = NULL;
|
||||
#endif
|
||||
|
||||
/* new_num allocates a number and sets fields to known values. */
|
||||
|
||||
@@ -100,20 +103,21 @@ bc_free_num (num)
|
||||
/* Intitialize the number package! */
|
||||
|
||||
void
|
||||
bc_init_numbers (TSRMLS_D)
|
||||
bc_init_numbers ()
|
||||
{
|
||||
BCG(_zero_) = bc_new_num (1,0);
|
||||
BCG(_one_) = bc_new_num (1,0);
|
||||
BCG(_one_)->n_value[0] = 1;
|
||||
BCG(_two_) = bc_new_num (1,0);
|
||||
BCG(_two_)->n_value[0] = 2;
|
||||
_zero_ = bc_new_num (1,0);
|
||||
_one_ = bc_new_num (1,0);
|
||||
_one_->n_value[0] = 1;
|
||||
_two_ = bc_new_num (1,0);
|
||||
_two_->n_value[0] = 2;
|
||||
}
|
||||
|
||||
|
||||
/* Make a copy of a number! Just increments the reference count! */
|
||||
|
||||
bc_num
|
||||
bc_copy_num (bc_num num)
|
||||
bc_copy_num (num)
|
||||
bc_num num;
|
||||
{
|
||||
num->n_refs++;
|
||||
return num;
|
||||
@@ -123,8 +127,9 @@ bc_copy_num (bc_num num)
|
||||
/* Initialize a number NUM by making it a copy of zero. */
|
||||
|
||||
void
|
||||
bc_init_num (bc_num *num TSRMLS_DC)
|
||||
bc_init_num (num)
|
||||
bc_num *num;
|
||||
{
|
||||
*num = bc_copy_num (BCG(_zero_));
|
||||
*num = bc_copy_num (_zero_);
|
||||
}
|
||||
|
||||
@@ -86,11 +86,15 @@ bc_out_long (val, size, space, out_char)
|
||||
as the routine to do the actual output of the characters. */
|
||||
|
||||
void
|
||||
bc_out_num (num, o_base, out_char, leading_zero)
|
||||
bc_num num;
|
||||
int o_base;
|
||||
#ifdef __STDC__
|
||||
bc_out_num (bc_num num, int o_base, void (*out_char)(int), int leading_zero TSRMLS_DC)
|
||||
void (*out_char)(int);
|
||||
#else
|
||||
bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_DC)
|
||||
void (*out_char)();
|
||||
#endif
|
||||
int leading_zero;
|
||||
{
|
||||
char *nptr;
|
||||
int index, fdigit, pre_space;
|
||||
@@ -101,7 +105,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
|
||||
if (num->n_sign == MINUS) (*out_char) ('-');
|
||||
|
||||
/* Output the number. */
|
||||
if (bc_is_zero (num TSRMLS_CC))
|
||||
if (bc_is_zero (num))
|
||||
(*out_char) ('0');
|
||||
else
|
||||
if (o_base == 10)
|
||||
@@ -114,7 +118,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
|
||||
else
|
||||
nptr++;
|
||||
|
||||
if (leading_zero && bc_is_zero (num TSRMLS_CC))
|
||||
if (leading_zero && bc_is_zero (num))
|
||||
(*out_char) ('0');
|
||||
|
||||
/* Now the fraction. */
|
||||
@@ -128,36 +132,36 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
|
||||
else
|
||||
{
|
||||
/* special case ... */
|
||||
if (leading_zero && bc_is_zero (num TSRMLS_CC))
|
||||
if (leading_zero && bc_is_zero (num))
|
||||
(*out_char) ('0');
|
||||
|
||||
/* The number is some other base. */
|
||||
digits = NULL;
|
||||
bc_init_num (&int_part TSRMLS_CC);
|
||||
bc_divide (num, BCG(_one_), &int_part, 0 TSRMLS_CC);
|
||||
bc_init_num (&frac_part TSRMLS_CC);
|
||||
bc_init_num (&cur_dig TSRMLS_CC);
|
||||
bc_init_num (&base TSRMLS_CC);
|
||||
bc_init_num (&int_part);
|
||||
bc_divide (num, _one_, &int_part, 0);
|
||||
bc_init_num (&frac_part);
|
||||
bc_init_num (&cur_dig);
|
||||
bc_init_num (&base);
|
||||
bc_sub (num, int_part, &frac_part, 0);
|
||||
/* Make the INT_PART and FRAC_PART positive. */
|
||||
int_part->n_sign = PLUS;
|
||||
frac_part->n_sign = PLUS;
|
||||
bc_int2num (&base, o_base);
|
||||
bc_init_num (&max_o_digit TSRMLS_CC);
|
||||
bc_init_num (&max_o_digit);
|
||||
bc_int2num (&max_o_digit, o_base-1);
|
||||
|
||||
|
||||
/* Get the digits of the integer part and push them on a stack. */
|
||||
while (!bc_is_zero (int_part TSRMLS_CC))
|
||||
while (!bc_is_zero (int_part))
|
||||
{
|
||||
bc_modulo (int_part, base, &cur_dig, 0 TSRMLS_CC);
|
||||
bc_modulo (int_part, base, &cur_dig, 0);
|
||||
/* PHP Change: malloc() -> emalloc() */
|
||||
temp = (stk_rec *) emalloc (sizeof(stk_rec));
|
||||
if (temp == NULL) bc_out_of_memory();
|
||||
temp->digit = bc_num2long (cur_dig);
|
||||
temp->next = digits;
|
||||
digits = temp;
|
||||
bc_divide (int_part, base, &int_part, 0 TSRMLS_CC);
|
||||
bc_divide (int_part, base, &int_part, 0);
|
||||
}
|
||||
|
||||
/* Print the digits on the stack. */
|
||||
@@ -181,9 +185,9 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
|
||||
{
|
||||
(*out_char) ('.');
|
||||
pre_space = 0;
|
||||
t_num = bc_copy_num (BCG(_one_));
|
||||
t_num = bc_copy_num (_one_);
|
||||
while (t_num->n_len <= num->n_scale) {
|
||||
bc_multiply (frac_part, base, &frac_part, num->n_scale TSRMLS_CC);
|
||||
bc_multiply (frac_part, base, &frac_part, num->n_scale);
|
||||
fdigit = bc_num2long (frac_part);
|
||||
bc_int2num (&int_part, fdigit);
|
||||
bc_sub (frac_part, int_part, &frac_part, 0);
|
||||
@@ -193,7 +197,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero TSRMLS_
|
||||
bc_out_long (fdigit, max_o_digit->n_len, pre_space, out_char);
|
||||
pre_space = 1;
|
||||
}
|
||||
bc_multiply (t_num, base, &t_num, 0 TSRMLS_CC);
|
||||
bc_multiply (t_num, base, &t_num, 0);
|
||||
}
|
||||
bc_free_num (&t_num);
|
||||
}
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
/* "Private" routines to bcmath. */
|
||||
|
||||
/* variables */
|
||||
#ifdef SANDER_0
|
||||
extern bc_num _bc_Free_list;
|
||||
#endif
|
||||
bc_num _bc_Free_list;
|
||||
|
||||
/* routines */
|
||||
int _bc_do_compare (bc_num n1, bc_num n2, int use_sign, int ignore_last);
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
only the integer part is used. */
|
||||
|
||||
void
|
||||
bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
|
||||
bc_raise (num1, num2, result, scale)
|
||||
bc_num num1, num2, *result;
|
||||
int scale;
|
||||
{
|
||||
bc_num temp, power;
|
||||
long exponent;
|
||||
@@ -64,7 +66,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
|
||||
if (exponent == 0)
|
||||
{
|
||||
bc_free_num (result);
|
||||
*result = bc_copy_num (BCG(_one_));
|
||||
*result = bc_copy_num (_one_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,7 +89,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
|
||||
while ((exponent & 1) == 0)
|
||||
{
|
||||
pwrscale = 2*pwrscale;
|
||||
bc_multiply (power, power, &power, pwrscale TSRMLS_CC);
|
||||
bc_multiply (power, power, &power, pwrscale);
|
||||
exponent = exponent >> 1;
|
||||
}
|
||||
temp = bc_copy_num (power);
|
||||
@@ -98,10 +100,10 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
|
||||
while (exponent > 0)
|
||||
{
|
||||
pwrscale = 2*pwrscale;
|
||||
bc_multiply (power, power, &power, pwrscale TSRMLS_CC);
|
||||
bc_multiply (power, power, &power, pwrscale);
|
||||
if ((exponent & 1) == 1) {
|
||||
calcscale = pwrscale + calcscale;
|
||||
bc_multiply (temp, power, &temp, calcscale TSRMLS_CC);
|
||||
bc_multiply (temp, power, &temp, calcscale);
|
||||
}
|
||||
exponent = exponent >> 1;
|
||||
}
|
||||
@@ -109,7 +111,7 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)
|
||||
/* Assign the value. */
|
||||
if (neg)
|
||||
{
|
||||
bc_divide (BCG(_one_), temp, result, rscale TSRMLS_CC);
|
||||
bc_divide (_one_, temp, result, rscale);
|
||||
bc_free_num (&temp);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -43,20 +43,22 @@
|
||||
only the integer part is used. */
|
||||
|
||||
int
|
||||
bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSRMLS_DC)
|
||||
bc_raisemod (base, expo, mod, result, scale)
|
||||
bc_num base, expo, mod, *result;
|
||||
int scale;
|
||||
{
|
||||
bc_num power, exponent, parity, temp;
|
||||
int rscale;
|
||||
|
||||
/* Check for correct numbers. */
|
||||
if (bc_is_zero(mod TSRMLS_CC)) return -1;
|
||||
if (bc_is_zero(mod)) return -1;
|
||||
if (bc_is_neg(expo)) return -1;
|
||||
|
||||
/* Set initial values. */
|
||||
power = bc_copy_num (base);
|
||||
exponent = bc_copy_num (expo);
|
||||
temp = bc_copy_num (BCG(_one_));
|
||||
bc_init_num(&parity TSRMLS_CC);
|
||||
temp = bc_copy_num (_one_);
|
||||
bc_init_num(&parity);
|
||||
|
||||
/* Check the base for scale digits. */
|
||||
if (base->n_scale != 0)
|
||||
@@ -66,7 +68,7 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSR
|
||||
if (exponent->n_scale != 0)
|
||||
{
|
||||
bc_rt_warn ("non-zero scale in exponent");
|
||||
bc_divide (exponent, BCG(_one_), &exponent, 0 TSRMLS_CC); /*truncate */
|
||||
bc_divide (exponent, _one_, &exponent, 0); /*truncate */
|
||||
}
|
||||
|
||||
/* Check the modulus for scale digits. */
|
||||
@@ -75,17 +77,17 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale TSR
|
||||
|
||||
/* Do the calculation. */
|
||||
rscale = MAX(scale, base->n_scale);
|
||||
while ( !bc_is_zero(exponent TSRMLS_CC) )
|
||||
while ( !bc_is_zero(exponent) )
|
||||
{
|
||||
(void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0 TSRMLS_CC);
|
||||
if ( !bc_is_zero(parity TSRMLS_CC) )
|
||||
(void) bc_divmod (exponent, _two_, &exponent, &parity, 0);
|
||||
if ( !bc_is_zero(parity) )
|
||||
{
|
||||
bc_multiply (temp, power, &temp, rscale TSRMLS_CC);
|
||||
(void) bc_modulo (temp, mod, &temp, scale TSRMLS_CC);
|
||||
bc_multiply (temp, power, &temp, rscale);
|
||||
(void) bc_modulo (temp, mod, &temp, scale);
|
||||
}
|
||||
|
||||
bc_multiply (power, power, &power, rscale TSRMLS_CC);
|
||||
(void) bc_modulo (power, mod, &power, scale TSRMLS_CC);
|
||||
bc_multiply (power, power, &power, rscale);
|
||||
(void) bc_modulo (power, mod, &power, scale);
|
||||
}
|
||||
|
||||
/* Assign the value. */
|
||||
|
||||
@@ -57,17 +57,13 @@ new_sub_num (length, scale, value)
|
||||
{
|
||||
bc_num temp;
|
||||
|
||||
#ifdef SANDER_0
|
||||
if (_bc_Free_list != NULL) {
|
||||
temp = _bc_Free_list;
|
||||
_bc_Free_list = temp->n_next;
|
||||
} else {
|
||||
#endif
|
||||
temp = (bc_num) emalloc (sizeof(bc_struct));
|
||||
#ifdef SANDER_0
|
||||
if (temp == NULL) bc_out_of_memory ();
|
||||
}
|
||||
#endif
|
||||
temp->n_sign = PLUS;
|
||||
temp->n_len = length;
|
||||
temp->n_scale = scale;
|
||||
@@ -180,7 +176,7 @@ _bc_shift_addsub (bc_num accum, bc_num val, int shift, int sub)
|
||||
*/
|
||||
static void
|
||||
_bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
|
||||
int full_scale TSRMLS_DC)
|
||||
int full_scale)
|
||||
{
|
||||
bc_num u0, u1, v0, v1;
|
||||
int u0len, v0len;
|
||||
@@ -201,14 +197,14 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
|
||||
|
||||
/* Split u and v. */
|
||||
if (ulen < n) {
|
||||
u1 = bc_copy_num (BCG(_zero_));
|
||||
u1 = bc_copy_num (_zero_);
|
||||
u0 = new_sub_num (ulen,0, u->n_value);
|
||||
} else {
|
||||
u1 = new_sub_num (ulen-n, 0, u->n_value);
|
||||
u0 = new_sub_num (n, 0, u->n_value+ulen-n);
|
||||
}
|
||||
if (vlen < n) {
|
||||
v1 = bc_copy_num (BCG(_zero_));
|
||||
v1 = bc_copy_num (_zero_);
|
||||
v0 = new_sub_num (vlen,0, v->n_value);
|
||||
} else {
|
||||
v1 = new_sub_num (vlen-n, 0, v->n_value);
|
||||
@@ -221,12 +217,12 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
|
||||
_bc_rm_leading_zeros (v0);
|
||||
v0len = v0->n_len;
|
||||
|
||||
m1zero = bc_is_zero(u1 TSRMLS_CC) || bc_is_zero(v1 TSRMLS_CC);
|
||||
m1zero = bc_is_zero(u1) || bc_is_zero(v1);
|
||||
|
||||
/* Calculate sub results ... */
|
||||
|
||||
bc_init_num(&d1 TSRMLS_CC);
|
||||
bc_init_num(&d2 TSRMLS_CC);
|
||||
bc_init_num(&d1);
|
||||
bc_init_num(&d2);
|
||||
bc_sub (u1, u0, &d1, 0);
|
||||
d1len = d1->n_len;
|
||||
bc_sub (v0, v1, &d2, 0);
|
||||
@@ -235,19 +231,19 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
|
||||
|
||||
/* Do recursive multiplies and shifted adds. */
|
||||
if (m1zero)
|
||||
m1 = bc_copy_num (BCG(_zero_));
|
||||
m1 = bc_copy_num (_zero_);
|
||||
else
|
||||
_bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0 TSRMLS_CC);
|
||||
_bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0);
|
||||
|
||||
if (bc_is_zero(d1 TSRMLS_CC) || bc_is_zero(d2 TSRMLS_CC))
|
||||
m2 = bc_copy_num (BCG(_zero_));
|
||||
if (bc_is_zero(d1) || bc_is_zero(d2))
|
||||
m2 = bc_copy_num (_zero_);
|
||||
else
|
||||
_bc_rec_mul (d1, d1len, d2, d2len, &m2, 0 TSRMLS_CC);
|
||||
_bc_rec_mul (d1, d1len, d2, d2len, &m2, 0);
|
||||
|
||||
if (bc_is_zero(u0 TSRMLS_CC) || bc_is_zero(v0 TSRMLS_CC))
|
||||
m3 = bc_copy_num (BCG(_zero_));
|
||||
if (bc_is_zero(u0) || bc_is_zero(v0))
|
||||
m3 = bc_copy_num (_zero_);
|
||||
else
|
||||
_bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0 TSRMLS_CC);
|
||||
_bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0);
|
||||
|
||||
/* Initialize product */
|
||||
prodlen = ulen+vlen+1;
|
||||
@@ -278,7 +274,9 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
|
||||
*/
|
||||
|
||||
void
|
||||
bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
|
||||
bc_multiply (n1, n2, prod, scale)
|
||||
bc_num n1, n2, *prod;
|
||||
int scale;
|
||||
{
|
||||
bc_num pval;
|
||||
int len1, len2;
|
||||
@@ -291,7 +289,7 @@ bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
|
||||
prod_scale = MIN(full_scale,MAX(scale,MAX(n1->n_scale,n2->n_scale)));
|
||||
|
||||
/* Do the multiply */
|
||||
_bc_rec_mul (n1, len1, n2, len2, &pval, full_scale TSRMLS_CC);
|
||||
_bc_rec_mul (n1, len1, n2, len2, &pval, full_scale);
|
||||
|
||||
/* Assign to prod and clean up the number. */
|
||||
pval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
|
||||
@@ -299,7 +297,7 @@ bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC)
|
||||
pval->n_len = len2 + len1 + 1 - full_scale;
|
||||
pval->n_scale = prod_scale;
|
||||
_bc_rm_leading_zeros (pval);
|
||||
if (bc_is_zero (pval TSRMLS_CC))
|
||||
if (bc_is_zero (pval))
|
||||
pval->n_sign = PLUS;
|
||||
bc_free_num (prod);
|
||||
*prod = pval;
|
||||
|
||||
@@ -42,14 +42,16 @@
|
||||
after the decimal place. */
|
||||
|
||||
int
|
||||
bc_sqrt (bc_num *num, int scale TSRMLS_DC)
|
||||
bc_sqrt (num, scale)
|
||||
bc_num *num;
|
||||
int scale;
|
||||
{
|
||||
int rscale, cmp_res, done;
|
||||
int cscale;
|
||||
bc_num guess, guess1, point5, diff;
|
||||
|
||||
/* Initial checks. */
|
||||
cmp_res = bc_compare (*num, BCG(_zero_));
|
||||
cmp_res = bc_compare (*num, _zero_);
|
||||
if (cmp_res < 0)
|
||||
return 0; /* error */
|
||||
else
|
||||
@@ -57,23 +59,23 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
|
||||
if (cmp_res == 0)
|
||||
{
|
||||
bc_free_num (num);
|
||||
*num = bc_copy_num (BCG(_zero_));
|
||||
*num = bc_copy_num (_zero_);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
cmp_res = bc_compare (*num, BCG(_one_));
|
||||
cmp_res = bc_compare (*num, _one_);
|
||||
if (cmp_res == 0)
|
||||
{
|
||||
bc_free_num (num);
|
||||
*num = bc_copy_num (BCG(_one_));
|
||||
*num = bc_copy_num (_one_);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize the variables. */
|
||||
rscale = MAX (scale, (*num)->n_scale);
|
||||
bc_init_num(&guess TSRMLS_CC);
|
||||
bc_init_num(&guess1 TSRMLS_CC);
|
||||
bc_init_num(&diff TSRMLS_CC);
|
||||
bc_init_num(&guess);
|
||||
bc_init_num(&guess1);
|
||||
bc_init_num(&diff);
|
||||
point5 = bc_new_num (1,1);
|
||||
point5->n_value[1] = 5;
|
||||
|
||||
@@ -82,7 +84,7 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
|
||||
if (cmp_res < 0)
|
||||
{
|
||||
/* The number is between 0 and 1. Guess should start at 1. */
|
||||
guess = bc_copy_num (BCG(_one_));
|
||||
guess = bc_copy_num (_one_);
|
||||
cscale = (*num)->n_scale;
|
||||
}
|
||||
else
|
||||
@@ -91,9 +93,9 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
|
||||
bc_int2num (&guess,10);
|
||||
|
||||
bc_int2num (&guess1,(*num)->n_len);
|
||||
bc_multiply (guess1, point5, &guess1, 0 TSRMLS_CC);
|
||||
bc_multiply (guess1, point5, &guess1, 0);
|
||||
guess1->n_scale = 0;
|
||||
bc_raise (guess, guess1, &guess, 0 TSRMLS_CC);
|
||||
bc_raise (guess, guess1, &guess, 0);
|
||||
bc_free_num (&guess1);
|
||||
cscale = 3;
|
||||
}
|
||||
@@ -104,9 +106,9 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
|
||||
{
|
||||
bc_free_num (&guess1);
|
||||
guess1 = bc_copy_num (guess);
|
||||
bc_divide (*num, guess, &guess, cscale TSRMLS_CC);
|
||||
bc_divide (*num, guess, &guess, cscale);
|
||||
bc_add (guess, guess1, &guess, 0);
|
||||
bc_multiply (guess, point5, &guess, cscale TSRMLS_CC);
|
||||
bc_multiply (guess, point5, &guess, cscale);
|
||||
bc_sub (guess, guess1, &diff, cscale+1);
|
||||
if (bc_is_near_zero (diff, cscale))
|
||||
{
|
||||
@@ -119,7 +121,7 @@ bc_sqrt (bc_num *num, int scale TSRMLS_DC)
|
||||
|
||||
/* Assign the number and clean up. */
|
||||
bc_free_num (num);
|
||||
bc_divide (guess,BCG(_one_),num,rscale TSRMLS_CC);
|
||||
bc_divide (guess,_one_,num,rscale);
|
||||
bc_free_num (&guess);
|
||||
bc_free_num (&guess1);
|
||||
bc_free_num (&point5);
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
/* Convert strings to bc numbers. Base 10 only.*/
|
||||
|
||||
void
|
||||
bc_str2num (bc_num *num, char *str, int scale TSRMLS_DC)
|
||||
bc_str2num (num, str, scale)
|
||||
bc_num *num;
|
||||
char *str;
|
||||
int scale;
|
||||
{
|
||||
int digits, strscale;
|
||||
char *ptr, *nptr;
|
||||
@@ -62,7 +65,7 @@ bc_str2num (bc_num *num, char *str, int scale TSRMLS_DC)
|
||||
while (isdigit((int)*ptr)) ptr++, strscale++; /* digits */
|
||||
if ((*ptr != '\0') || (digits+strscale == 0))
|
||||
{
|
||||
*num = bc_copy_num (BCG(_zero_));
|
||||
*num = bc_copy_num (_zero_);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,14 @@
|
||||
/* In some places we need to check if the number NUM is zero. */
|
||||
|
||||
char
|
||||
bc_is_zero (bc_num num TSRMLS_DC)
|
||||
bc_is_zero (num)
|
||||
bc_num num;
|
||||
{
|
||||
int count;
|
||||
char *nptr;
|
||||
|
||||
/* Quick check. */
|
||||
if (num == BCG(_zero_)) return TRUE;
|
||||
if (num == _zero_) return TRUE;
|
||||
|
||||
/* Initialize */
|
||||
count = num->n_len + num->n_scale;
|
||||
|
||||
+2
-22
@@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
| Copyright (c) 1997-2002 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 |
|
||||
@@ -23,32 +23,12 @@
|
||||
|
||||
#if WITH_BCMATH
|
||||
|
||||
#include "libbcmath/src/bcmath.h"
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(bcmath)
|
||||
bc_num _zero_;
|
||||
bc_num _one_;
|
||||
bc_num _two_;
|
||||
ZEND_END_MODULE_GLOBALS(bcmath)
|
||||
|
||||
#if ZTS
|
||||
# define BCG(v) TSRMG(bcmath_globals_id, zend_bcmath_globals *, v)
|
||||
extern int bcmath_globals_id;
|
||||
#else
|
||||
# define BCG(v) (bcmath_globals.v)
|
||||
extern zend_bcmath_globals bcmath_globals;
|
||||
#endif
|
||||
|
||||
#define BC
|
||||
|
||||
extern zend_module_entry bcmath_module_entry;
|
||||
#define phpext_bcmath_ptr &bcmath_module_entry
|
||||
|
||||
#if ZTS
|
||||
PHP_MINIT_FUNCTION(bcmath);
|
||||
#endif
|
||||
PHP_MSHUTDOWN_FUNCTION(bcmath);
|
||||
PHP_RINIT_FUNCTION(bcmath);
|
||||
PHP_RSHUTDOWN_FUNCTION(bcmath);
|
||||
PHP_MINFO_FUNCTION(bcmath);
|
||||
|
||||
PHP_FUNCTION(bcadd);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# $Source$
|
||||
# $Id$
|
||||
|
||||
define_option enable-bcmath 'Enable bc style precision math functions' yesno \
|
||||
yes \
|
||||
' Enables bc style arbitrary precision math functions.'
|
||||
@@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
bcadd() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcadd("1", "2"),"\n";
|
||||
echo bcadd("-1", "5", 4),"\n";
|
||||
echo bcadd("1928372132132819737213", "8728932001983192837219398127471", 2),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
3
|
||||
4.0000
|
||||
8728932003911564969352217864684.00
|
||||
@@ -1,18 +0,0 @@
|
||||
--TEST--
|
||||
bccomp() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bccomp("-1", "5", 4),"\n";
|
||||
echo bccomp("1928372132132819737213", "8728932001983192837219398127471"),"\n";
|
||||
echo bccomp("1.00000000000000000001", "1", 2),"\n";
|
||||
echo bccomp("97321", "2321"),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
-1
|
||||
-1
|
||||
0
|
||||
1
|
||||
@@ -1,18 +0,0 @@
|
||||
--TEST--
|
||||
bcdiv() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcdiv("1", "2"),"\n";
|
||||
echo bcdiv("1", "2", 2),"\n";
|
||||
echo bcdiv("-1", "5", 4),"\n";
|
||||
echo bcdiv("8728932001983192837219398127471", "1928372132132819737213", 2),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
0
|
||||
0.50
|
||||
-0.2000
|
||||
4526580661.75
|
||||
@@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
bcmod() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcmod("11", "2"),"\n";
|
||||
echo bcmod("-1", "5"),"\n";
|
||||
echo bcmod("8728932001983192837219398127471", "1928372132132819737213"),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
1
|
||||
-1
|
||||
1459434331351930289678
|
||||
@@ -1,18 +0,0 @@
|
||||
--TEST--
|
||||
bcmul() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcmul("1", "2"),"\n";
|
||||
echo bcmul("-3", "5"),"\n";
|
||||
echo bcmul("1234567890", "9876543210"),"\n";
|
||||
echo bcmul("2.5", "1.5", 2),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
2
|
||||
-15
|
||||
12193263111263526900
|
||||
3.75
|
||||
@@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
bcpow() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcpow("1", "2"),"\n";
|
||||
echo bcpow("-2", "5", 4),"\n";
|
||||
echo bcpow("2", "64"),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
1
|
||||
-32
|
||||
18446744073709551616
|
||||
@@ -1,21 +0,0 @@
|
||||
--TEST--
|
||||
bcscale() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcadd("1", "2"),"\n";
|
||||
bcscale(2);
|
||||
echo bcadd("1", "2"),"\n";
|
||||
bcscale(10);
|
||||
echo bcadd("1", "2"),"\n";
|
||||
bcscale(0);
|
||||
echo bcadd("1", "2"),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
3
|
||||
3.00
|
||||
3.0000000000
|
||||
3
|
||||
@@ -1,14 +0,0 @@
|
||||
--TEST--
|
||||
bcsqrt() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcsqrt("9"),"\n";
|
||||
echo bcsqrt("1928372132132819737213", 5),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
3
|
||||
43913234134.28826
|
||||
@@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
bcsub() function
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
echo bcsub("1", "2"),"\n";
|
||||
echo bcsub("-1", "5", 4),"\n";
|
||||
echo bcsub("8728932001983192837219398127471", "1928372132132819737213", 2),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
-1
|
||||
-6.0000
|
||||
8728932000054820705086578390258.00
|
||||
@@ -1,2 +0,0 @@
|
||||
Bzip2
|
||||
Sterling Hughes
|
||||
-528
@@ -1,528 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sterling Hughes <sterling@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_bz2.h"
|
||||
|
||||
#if HAVE_BZ2
|
||||
|
||||
/* PHP Includes */
|
||||
#include "ext/standard/file.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
|
||||
/* for fileno() */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Internal error constants */
|
||||
#define PHP_BZ_ERRNO 0
|
||||
#define PHP_BZ_ERRSTR 1
|
||||
#define PHP_BZ_ERRBOTH 2
|
||||
|
||||
/* Blocksize of the decompression buffer */
|
||||
#define PHP_BZ_DECOMPRESS_SIZE 4096
|
||||
|
||||
function_entry bz2_functions[] = {
|
||||
PHP_FE(bzopen, NULL)
|
||||
PHP_FE(bzread, NULL)
|
||||
PHP_FALIAS(bzwrite, fwrite, NULL)
|
||||
PHP_FALIAS(bzflush, fflush, NULL)
|
||||
PHP_FALIAS(bzclose, fclose, NULL)
|
||||
PHP_FE(bzerrno, NULL)
|
||||
PHP_FE(bzerrstr, NULL)
|
||||
PHP_FE(bzerror, NULL)
|
||||
PHP_FE(bzcompress, NULL)
|
||||
PHP_FE(bzdecompress, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
zend_module_entry bz2_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"bz2",
|
||||
bz2_functions,
|
||||
PHP_MINIT(bz2),
|
||||
PHP_MSHUTDOWN(bz2),
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(bz2),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_BZ2
|
||||
ZEND_GET_MODULE(bz2)
|
||||
#endif
|
||||
|
||||
struct php_bz2_stream_data_t {
|
||||
BZFILE *bz_file;
|
||||
php_stream *stream;
|
||||
};
|
||||
|
||||
/* {{{ BZip2 stream implementation */
|
||||
|
||||
static size_t php_bz2iop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
size_t ret;
|
||||
|
||||
ret = BZ2_bzread(self->bz_file, buf, count);
|
||||
|
||||
if (ret == 0) {
|
||||
stream->eof = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
|
||||
return BZ2_bzwrite(self->bz_file, (char*)buf, count);
|
||||
}
|
||||
|
||||
static int php_bz2iop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract;
|
||||
int ret = EOF;
|
||||
|
||||
if (close_handle) {
|
||||
BZ2_bzclose(self->bz_file);
|
||||
}
|
||||
|
||||
if (self->stream) {
|
||||
php_stream_free(self->stream, PHP_STREAM_FREE_CLOSE | (close_handle == 0 ? PHP_STREAM_FREE_PRESERVE_HANDLE : 0));
|
||||
}
|
||||
|
||||
efree(self);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int php_bz2iop_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract;
|
||||
return BZ2_bzflush(self->bz_file);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
php_stream_ops php_stream_bz2io_ops = {
|
||||
php_bz2iop_write, php_bz2iop_read,
|
||||
php_bz2iop_close, php_bz2iop_flush,
|
||||
"BZip2",
|
||||
NULL, /* seek */
|
||||
NULL, /* cast */
|
||||
NULL, /* stat */
|
||||
NULL /* set_option */
|
||||
};
|
||||
|
||||
/* {{{ Bzip2 stream openers */
|
||||
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
|
||||
char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
struct php_bz2_stream_data_t *self;
|
||||
|
||||
self = emalloc(sizeof(*self));
|
||||
|
||||
self->stream = innerstream;
|
||||
self->bz_file = bz;
|
||||
|
||||
return php_stream_alloc_rel(&php_stream_bz2io_ops, self, 0, mode);
|
||||
}
|
||||
|
||||
PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
char *path,
|
||||
char *mode,
|
||||
int options,
|
||||
char **opened_path,
|
||||
php_stream_context *context STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *retstream = NULL, *stream = NULL;
|
||||
char *path_copy = NULL;
|
||||
BZFILE *bz_file = NULL;
|
||||
|
||||
if (strncasecmp("compress.bzip2://", path, 17) == 0) {
|
||||
path += 17;
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL_DIR
|
||||
virtual_filepath(path, &path_copy TSRMLS_CC);
|
||||
#else
|
||||
path_copy = path;
|
||||
#endif
|
||||
|
||||
/* try and open it directly first */
|
||||
bz_file = BZ2_bzopen(path_copy, mode);
|
||||
|
||||
if (opened_path && bz_file) {
|
||||
*opened_path = estrdup(path_copy);
|
||||
}
|
||||
path_copy = NULL;
|
||||
|
||||
if (bz_file == NULL) {
|
||||
/* that didn't work, so try and get something from the network/wrapper */
|
||||
stream = php_stream_open_wrapper(path, mode, options, opened_path);
|
||||
|
||||
if (stream) {
|
||||
int fd;
|
||||
if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
|
||||
bz_file = BZ2_bzdopen(fd, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bz_file) {
|
||||
retstream = _php_stream_bz2open_from_BZFILE(bz_file, mode, stream STREAMS_REL_CC TSRMLS_CC);
|
||||
if (retstream) {
|
||||
return retstream;
|
||||
}
|
||||
|
||||
BZ2_bzclose(bz_file);
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
php_stream_close(stream);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
static php_stream_wrapper_ops bzip2_stream_wops = {
|
||||
_php_stream_bz2open,
|
||||
NULL, /* close */
|
||||
NULL, /* fstat */
|
||||
NULL, /* stat */
|
||||
NULL, /* opendir */
|
||||
"BZip2"
|
||||
};
|
||||
|
||||
php_stream_wrapper php_stream_bzip2_wrapper = {
|
||||
&bzip2_stream_wops,
|
||||
NULL,
|
||||
0 /* is_url */
|
||||
};
|
||||
|
||||
static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int);
|
||||
|
||||
PHP_MINIT_FUNCTION(bz2)
|
||||
{
|
||||
php_register_url_stream_wrapper("compress.bzip2", &php_stream_bzip2_wrapper TSRMLS_CC);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(bz2)
|
||||
{
|
||||
php_unregister_url_stream_wrapper("compress.bzip2" TSRMLS_CC);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINFO_FUNCTION(bz2)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "BZip2 Support", "Enabled");
|
||||
php_info_print_table_row(2, "BZip2 Version", (char *) BZ2_bzlibVersion());
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
/* {{{ proto string bzread(int bz[, int length])
|
||||
Reads up to length bytes from a BZip2 stream, or 1024 bytes if length is not specified */
|
||||
PHP_FUNCTION(bzread)
|
||||
{
|
||||
zval *bz;
|
||||
long len = 1024;
|
||||
php_stream *stream;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &bz, &len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_stream_from_zval(stream, &bz);
|
||||
|
||||
if (len < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "length may not be negative");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
Z_STRVAL_P(return_value) = emalloc(len + 1);
|
||||
Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len);
|
||||
|
||||
if (Z_STRLEN_P(return_value) < 0) {
|
||||
efree(Z_STRVAL_P(return_value));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not read valid bz2 data from stream");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
|
||||
|
||||
if (PG(magic_quotes_runtime)) {
|
||||
Z_STRVAL_P(return_value) = php_addslashes( Z_STRVAL_P(return_value),
|
||||
Z_STRLEN_P(return_value),
|
||||
&Z_STRLEN_P(return_value), 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
Z_TYPE_P(return_value) = IS_STRING;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource bzopen(string|int file|fp, string mode)
|
||||
Opens a new BZip2 stream */
|
||||
PHP_FUNCTION(bzopen)
|
||||
{
|
||||
zval **file, /* The file to open */
|
||||
**mode; /* The mode to open the stream with */
|
||||
BZFILE *bz; /* The compressed file stream */
|
||||
php_stream *stream = NULL;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &file, &mode) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(mode);
|
||||
|
||||
/* If it's not a resource its a string containing the filename to open */
|
||||
if (Z_TYPE_PP(file) != IS_RESOURCE) {
|
||||
convert_to_string_ex(file);
|
||||
stream = php_stream_bz2open(NULL,
|
||||
Z_STRVAL_PP(file),
|
||||
Z_STRVAL_PP(mode),
|
||||
ENFORCE_SAFE_MODE | REPORT_ERRORS,
|
||||
NULL);
|
||||
} else {
|
||||
/* If it is a resource, than its a stream resource */
|
||||
int fd;
|
||||
|
||||
php_stream_from_zval(stream, file);
|
||||
|
||||
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void *) &fd, REPORT_ERRORS)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
bz = BZ2_bzdopen(fd, Z_STRVAL_PP(mode));
|
||||
|
||||
stream = php_stream_bz2open_from_BZFILE(bz, Z_STRVAL_PP(mode), stream);
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
php_stream_to_zval(stream, return_value);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int bzerrno(resource bz)
|
||||
Returns the error number */
|
||||
PHP_FUNCTION(bzerrno)
|
||||
{
|
||||
php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRNO);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bzerrstr(resource bz)
|
||||
Returns the error string */
|
||||
PHP_FUNCTION(bzerrstr)
|
||||
{
|
||||
php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRSTR);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array bzerror(resource bz)
|
||||
Returns the error number and error string in an associative array */
|
||||
PHP_FUNCTION(bzerror)
|
||||
{
|
||||
php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRBOTH);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bzcompress(string source [, int blocksize100k [, int workfactor]])
|
||||
Compresses a string into BZip2 encoded data */
|
||||
PHP_FUNCTION(bzcompress)
|
||||
{
|
||||
zval **source, /* Source data to compress */
|
||||
**zblock_size, /* Optional block size to use */
|
||||
**zwork_factor; /* Optional work factor to use */
|
||||
char *dest = NULL; /* Destination to place the compressed data into */
|
||||
int error, /* Error Container */
|
||||
block_size = 4, /* Block size for compression algorithm */
|
||||
work_factor = 0, /* Work factor for compression algorithm */
|
||||
argc; /* Argument count */
|
||||
unsigned int source_len, /* Length of the source data */
|
||||
dest_len; /* Length of the destination buffer */
|
||||
|
||||
argc = ZEND_NUM_ARGS();
|
||||
|
||||
if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &source, &zblock_size, &zwork_factor) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(source);
|
||||
|
||||
/* Assign them to easy to use variables, dest_len is initially the length of the data
|
||||
+ .01 x length of data + 600 which is the largest size the results of the compression
|
||||
could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net
|
||||
for pointing this out). */
|
||||
source_len = Z_STRLEN_PP(source);
|
||||
dest_len = Z_STRLEN_PP(source) + (0.01 * Z_STRLEN_PP(source)) + 600;
|
||||
|
||||
/* Allocate the destination buffer */
|
||||
dest = emalloc(dest_len + 1);
|
||||
|
||||
/* Handle the optional arguments */
|
||||
if (argc > 1) {
|
||||
convert_to_long_ex(zblock_size);
|
||||
block_size = Z_LVAL_PP(zblock_size);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
convert_to_long_ex(zwork_factor);
|
||||
work_factor = Z_LVAL_PP(zwork_factor);
|
||||
}
|
||||
|
||||
error = BZ2_bzBuffToBuffCompress(dest, &dest_len, Z_STRVAL_PP(source), source_len, block_size, 0, work_factor);
|
||||
if (error != BZ_OK) {
|
||||
efree(dest);
|
||||
RETURN_LONG(error);
|
||||
} else {
|
||||
/* Copy the buffer, we have perhaps allocate alot more than we need,
|
||||
so we erealloc() the buffer to the proper size */
|
||||
dest = erealloc(dest, dest_len + 1);
|
||||
dest[dest_len] = 0;
|
||||
RETURN_STRINGL(dest, dest_len, 0);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bzdecompress(string source [, int small])
|
||||
Decompresses BZip2 compressed data */
|
||||
PHP_FUNCTION(bzdecompress)
|
||||
{
|
||||
zval **source, /* Source data to decompress */
|
||||
**zsmall; /* (Optional) user specified small */
|
||||
char *dest; /* Destination buffer, initially allocated */
|
||||
int error, /* Error container */
|
||||
iter = 1, /* Iteration count for the compression loop */
|
||||
size, /* Current size to realloc the dest buffer to */
|
||||
dest_len = PHP_BZ_DECOMPRESS_SIZE, /* Size of the destination length */
|
||||
small = 0, /* The actual small */
|
||||
argc = ZEND_NUM_ARGS(); /* Argument count */
|
||||
|
||||
if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &source, &zsmall) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_string_ex(source);
|
||||
|
||||
/* optional small argument handling */
|
||||
if (argc > 1) {
|
||||
convert_to_long_ex(zsmall);
|
||||
small = Z_LVAL_PP(zsmall);
|
||||
}
|
||||
|
||||
/* Depending on the size of the source buffer, either allocate
|
||||
the length of the source buffer or the a default decompression
|
||||
size */
|
||||
dest = emalloc(PHP_BZ_DECOMPRESS_SIZE > Z_STRLEN_PP(source) ? PHP_BZ_DECOMPRESS_SIZE : Z_STRLEN_PP(source));
|
||||
|
||||
/* (de)Compression Loop */
|
||||
do {
|
||||
/* Handle the (re)allocation of the buffer */
|
||||
size = dest_len * iter;
|
||||
if (iter > 1) {
|
||||
dest = erealloc(dest, size);
|
||||
}
|
||||
++iter;
|
||||
|
||||
/* Perform the decompression */
|
||||
error = BZ2_bzBuffToBuffDecompress(dest, &size, Z_STRVAL_PP(source), Z_STRLEN_PP(source), small, 0);
|
||||
} while (error == BZ_OUTBUFF_FULL);
|
||||
|
||||
if (error != BZ_OK) {
|
||||
efree(dest);
|
||||
RETURN_LONG(error);
|
||||
} else {
|
||||
/* we might have allocated a little to much, so erealloc the buffer
|
||||
down to size, before returning it */
|
||||
dest = erealloc(dest, size + 1);
|
||||
dest[size] = 0;
|
||||
RETURN_STRINGL(dest, size, 0);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_bz2_error()
|
||||
The central error handling interface, does the work for bzerrno, bzerrstr and bzerror */
|
||||
static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
{
|
||||
zval **bzp; /* BZip2 Resource Pointer */
|
||||
php_stream *stream;
|
||||
const char *errstr; /* Error string */
|
||||
int errnum; /* Error number */
|
||||
struct php_bz2_stream_data_t *self;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &bzp) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
php_stream_from_zval(stream, bzp);
|
||||
|
||||
if (!php_stream_is(stream, PHP_STREAM_IS_BZIP2)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
self = (struct php_bz2_stream_data_t *) stream->abstract;
|
||||
|
||||
/* Fetch the error information */
|
||||
errstr = BZ2_bzerror(self->bz_file, &errnum);
|
||||
|
||||
/* Determine what to return */
|
||||
switch (opt) {
|
||||
case PHP_BZ_ERRNO:
|
||||
RETURN_LONG(errnum);
|
||||
break;
|
||||
case PHP_BZ_ERRSTR:
|
||||
RETURN_STRING((char*)errstr, 1);
|
||||
break;
|
||||
case PHP_BZ_ERRBOTH:
|
||||
array_init(return_value);
|
||||
|
||||
add_assoc_long (return_value, "errno", errnum);
|
||||
add_assoc_string(return_value, "errstr", (char*)errstr, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: fdm=marker
|
||||
* vim: noet sw=4 ts=4
|
||||
*/
|
||||
Loaded 100 of 1976 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user