fputs($fp, "#ifndef PHP_HAVE_{$upname}\n\n");
+ if(isset($this->headers)) {
+ foreach($this->headers as $header) {
+ if (@$header["prepend"] === "yes") {
+ fputs($fp, "#include <$header[name]>\n");
+ }
+ }
+ }
+
+ fputs($fp, '
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <php.h>
+#include <php_ini.h>
+#include <SAPI.h>
+#include <ext/standard/info.h>
+
+');
+
+ if(isset($this->headers)) {
+ foreach($this->headers as $header) {
+ if (@$header["prepend"] !== "yes") {
+ fputs($fp, "#include <$header[name]>\n");
+ }
+ }
+ }
+
+ if(isset($this->code["header"])) {
+ foreach($this->code["header"] as $code) {
+ fputs($fp, $code);
+ }
+ }
+
fputs($fp, "
extern zend_module_entry {$this->name}_module_entry;
#define phpext_{$this->name}_ptr &{$this->name}_module_entry
$code = "";
foreach($this->functions as $function) {
- $code .= $function->c_code();
+ $code .= $function->c_code(&$this);
}
return $code;
fputs($fp, $this->get_license());
- fputs($fp, '
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <php.h>
-#include <php_ini.h>
-#include <SAPI.h>
-#include <ext/standard/info.h>
-
-');
fputs($fp, "#include \"php_{$this->name}.h\"\n\n");
if (isset($this->logo)) {
fputs($fp, "ZEND_DECLARE_MODULE_GLOBALS({$this->name})\n\n");
}
+ fputs($fp, $this->private_functions_c());
+
if (!empty($this->resources)) {
foreach ($this->resources as $resource) {
fputs($fp, $resource->c_code());
fputs($fp, $this->internal_functions_c());
- fputs($fp, $this->private_functions_c());
-
fputs($fp, $this->public_functions_c());
fputs($fp, $this->editor_config_c());