Skip to content

Commit f7490c4

Browse files
author
Hartmut Holzgraefe
committed
forgot to add these two on my last commit :(
1 parent 189d290 commit f7490c4

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

scripts/ext_skel_ng/php_logo.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
class php_logo extends php_element {
4+
function php_logo($name, $attr) {
5+
$this->name = $name;
6+
$this->attr = $attr;
7+
$this->id = '"'.strtoupper($name).'_LOGO_ID"';
8+
9+
$this->data = file_get_contents($attr['src']);
10+
$this->size = strlen($this->data);
11+
12+
$this->mime_type = "image/gif";
13+
}
14+
15+
function docbook_xml($base) {
16+
return "";
17+
}
18+
19+
function minit_code() {
20+
return " php_register_info_logo({$this->id}, \"{$this->mime_type}\", {$this->name}_logo, {$this->size});\n";
21+
}
22+
23+
function c_code() {
24+
return "
25+
static unsigned char {$this->name}_logo[] = {
26+
#include \"{$this->name}_logo.h\"
27+
};
28+
";
29+
}
30+
31+
function h_code() {
32+
$len = strlen($this->data);
33+
$code = " ";
34+
$i=0;
35+
for($n = 0; $n < $len; $n++) {
36+
$code .= sprintf(" %3d",ord($this->data[$n]));
37+
if($n == $len - 1) break;
38+
$code .= ",";
39+
if(++$i==8) {
40+
$code .= "\n ";
41+
$i=0;
42+
}
43+
}
44+
45+
$code .= "\n";
46+
47+
return $code;
48+
}
49+
}
50+
51+
?>

scripts/ext_skel_ng/php_resource.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
class php_resource extends php_element {
4+
function php_resource($name, $payload, $destruct, $description) {
5+
$this->name = $name;
6+
$this->payload = $payload;
7+
$this->destruct = $destruct;
8+
$this->description = $description;
9+
10+
if (empty($this->destruct) && strstr($this->payload, "*")) {
11+
$this->destruct = " free(resource);\n";
12+
}
13+
14+
if(empty($this->payload)) {
15+
$this->payload = "int";
16+
}
17+
}
18+
19+
function docbook_xml($base) {
20+
return "
21+
<section id='$base.resources.{$this->name}'>
22+
<title><litera>{$this->name}</literal></title>
23+
<para>
24+
{$this->description}
25+
</para>
26+
</section>
27+
";
28+
}
29+
30+
function minit_code() {
31+
return "
32+
le_{$this->name} = zend_register_list_destructors_ex({$this->name}_dtor,
33+
NULL,
34+
\"{$this->name}\",
35+
module_number);
36+
37+
";
38+
}
39+
40+
function c_code() {
41+
return "
42+
int le_{$this->name};
43+
44+
void {$this->name}_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
45+
{
46+
{$this->payload} resource = ({$this->payload})(rsrc->ptr);
47+
48+
{$this->destruct}
49+
}
50+
";
51+
}
52+
53+
function h_code() {
54+
$upname = strtoupper($this->name);
55+
56+
return "
57+
#define {$upname}_FETCH(r, z) ZEND_FETCH_RESOURCE(r, {$this->payload}, z, -1, ${$this->name}, le_{$this->name }); \
58+
if(!r) { RETURN_FALSE; }
59+
60+
#define {$upname}_REGISTER(r) ZEND_REGISTER_RESOURCE(return_value, r, le_{$this->name });
61+
";
62+
}
63+
}
64+
65+
?>

0 commit comments

Comments
 (0)