bcompiler_write_exe_footer

(no version information, might be only in CVS)

bcompiler_write_exe_footer -- Writes the the start pos, and sig to the end of a exe type file

Description

bool bcompiler_write_exe_footer ( resource filehandle, int startpos )

Warning

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

An EXE (or self executable) file consists of 3 parts,

The Executable code (eg. a compiled C program that can initiate call the PHP bcompiler)
The Bzip encoded Bytecodes
The bcompiler exe footer

The startpos is the position of in the file at which the Bzip encoded bytecodes start, and can be obtained using ftell($fh).

Example 1. bcompiler_write_footer() example

<?php
$fh
= fopen("/tmp/example.exe","w");
$size = filesize("/tmp/base.exe");
$fr = fopen("/tmp/base.exe","r");
fwrite($fh,fread($fr,$size),$size);
$startpos = ftell($fh);
/* write bytecodes compressed */
$fz = bzopen($fh,"w");
bcompiler_write_header($fz);
bcompiler_write_class($fz,"DB");
bcompiler_write_class($fz,"DB_common");
bcompiler_write_footer($fz);
/* write footer exe uncompressed */
bcompiler_write_exe_footer($fh,$startpos);
fclose($fh);

?>

See also bcompiler_write_header(), bcompiler_write_class(), and bcompiler_write_footer().