Last commit for php_imlib.h: a2f603174ce34359dde60b6227d138b5bf330503

Revert "Quick and dirty PHP7 port."

Piotr Pawłow [2016-09-14 15:21:01]
Revert "Quick and dirty PHP7 port."

This reverts commit 87380c76cb1eb3644da7291d842281caaae63f2d.
There are much more differences between PHP5 and 7 than I anticipated.
The code doesn't work right.
/*
   +----------------------------------------------------------------------+
   | PHP version 4.0                                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group                   |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Original author: Matt McClanahan <cardinal@dodds.net>                |
   | Current maintainer: Piotr Pawlow <pp@siedziba.pl>                    |
   +----------------------------------------------------------------------+
 */

#ifndef _PHP_IMLIB_H
#define _PHP_IMLIB_H

#include "X11/Xlib.h"
#include <Imlib2.h>
#include "ltdl.h"
#include "php_ini.h"
#include "php_config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#if HAVE_LIBT1
#ifndef T1_DEFAULT
#include <t1lib.h>
#endif
#endif

#if HAVE_IMLIB

#ifdef ZTS
#include "TSRM.h"
#endif

extern zend_module_entry imlib_module_entry;
#define phpext_imlib_ptr &imlib_module_entry

#ifdef PHP_WIN32
#define PHP_IMLIB_API __declspec(dllexport)
#else
#define PHP_IMLIB_API
#endif

PHP_MINIT_FUNCTION(imlib);
PHP_MSHUTDOWN_FUNCTION(imlib);
PHP_RINIT_FUNCTION(imlib);
PHP_RSHUTDOWN_FUNCTION(imlib);
PHP_MINFO_FUNCTION(imlib);

PHP_INI_MH(OnUpdateFontCacheSize);

PHP_FUNCTION(imlib_add_color_to_color_range);
PHP_FUNCTION(imlib_blend_image_onto_image);
PHP_FUNCTION(imlib_clone_image);
PHP_FUNCTION(imlib_create_color_range);
PHP_FUNCTION(imlib_create_color_modifier);
PHP_FUNCTION(imlib_create_cropped_image);
PHP_FUNCTION(imlib_create_cropped_scaled_image);
PHP_FUNCTION(imlib_create_image);
PHP_FUNCTION(imlib_create_rotated_image);
PHP_FUNCTION(imlib_create_scaled_image);
PHP_FUNCTION(imlib_free_color_range);
PHP_FUNCTION(imlib_free_color_modifier);
PHP_FUNCTION(imlib_free_font);
PHP_FUNCTION(imlib_free_image);
PHP_FUNCTION(imlib_get_text_size);
PHP_FUNCTION(imlib_get_text_advance);
PHP_FUNCTION(imlib_image_blur);
PHP_FUNCTION(imlib_image_draw_ellipse);
PHP_FUNCTION(imlib_image_draw_line);
PHP_FUNCTION(imlib_image_draw_polygon);
PHP_FUNCTION(imlib_image_draw_rectangle);
PHP_FUNCTION(imlib_image_fill_color_range_rectangle);
PHP_FUNCTION(imlib_image_fill_ellipse);
PHP_FUNCTION(imlib_image_fill_polygon);
PHP_FUNCTION(imlib_image_fill_rectangle);
PHP_FUNCTION(imlib_image_flip_horizontal);
PHP_FUNCTION(imlib_image_flip_vertical);
PHP_FUNCTION(imlib_image_flip_diagonal);
PHP_FUNCTION(imlib_image_orientate);
PHP_FUNCTION(imlib_image_format);
PHP_FUNCTION(imlib_image_get_filename);
PHP_FUNCTION(imlib_image_get_height);
PHP_FUNCTION(imlib_image_get_width);
PHP_FUNCTION(imlib_image_has_alpha);
PHP_FUNCTION(imlib_image_modify_alpha);
PHP_FUNCTION(imlib_image_set_format);
PHP_FUNCTION(imlib_image_sharpen);
PHP_FUNCTION(imlib_image_tile_horizontal);
PHP_FUNCTION(imlib_image_tile_vertical);
PHP_FUNCTION(imlib_image_tile);
PHP_FUNCTION(imlib_list_fonts);
PHP_FUNCTION(imlib_load_font);
PHP_FUNCTION(imlib_load_image);
PHP_FUNCTION(imlib_load_image_with_error_return);
PHP_FUNCTION(imlib_polygon_add_point);
PHP_FUNCTION(imlib_polygon_contains_point);
PHP_FUNCTION(imlib_polygon_free);
PHP_FUNCTION(imlib_polygon_get_bounds);
PHP_FUNCTION(imlib_polygon_new);
PHP_FUNCTION(imlib_save_image);
PHP_FUNCTION(imlib_dump_image);
PHP_FUNCTION(imlib_text_draw);
PHP_FUNCTION(imlib_get_cache_size);
PHP_FUNCTION(imlib_set_cache_size);
PHP_FUNCTION(imlib_apply_filter);
PHP_FUNCTION(imlib_create_filter);
PHP_FUNCTION(imlib_free_filter);
PHP_FUNCTION(imlib_image_filter);
PHP_FUNCTION(imlib_filter_set);
PHP_FUNCTION(imlib_filter_set_alpha);
PHP_FUNCTION(imlib_filter_set_red);
PHP_FUNCTION(imlib_filter_set_green);
PHP_FUNCTION(imlib_filter_set_blue);
PHP_FUNCTION(imlib_filter_constants);
PHP_FUNCTION(imlib_filter_divisors);
PHP_FUNCTION(imlib_modify_color_modifier_gamma);
PHP_FUNCTION(imlib_modify_color_modifier_brightness);
PHP_FUNCTION(imlib_modify_color_modifier_contrast);
PHP_FUNCTION(imlib_reset_color_modifier);
PHP_FUNCTION(imlib_apply_color_modifier);
PHP_FUNCTION(imlib_set_color_modifier);
PHP_FUNCTION(imlib_get_color_modifier);
PHP_FUNCTION(imlib_psloadfont);
PHP_FUNCTION(imlib_psfreefont);
PHP_FUNCTION(imlib_psencodefont);
PHP_FUNCTION(imlib_psextendfont);
PHP_FUNCTION(imlib_psslantfont);
PHP_FUNCTION(imlib_pstext);
PHP_FUNCTION(imlib_psbbox);


typedef struct
{
    Imlib_Font font;
    Imlib_TTF_Encoding enc;
} PHP_Imlib_Font_struct;
typedef PHP_Imlib_Font_struct *PHP_Imlib_Font;

typedef struct
{
    Imlib_Color_Modifier cm;
    DATA8 channels[4][256];
    int modified;
    int valid;
} PHP_Imlib_Color_Modifier_struct;
typedef PHP_Imlib_Color_Modifier_struct *PHP_Imlib_Color_Modifier;

#if PHP_VERSION_ID >= 70000
  typedef zval imlib_zval;
  typedef zend_resource imlib_resource;
# define IMLIB_TO_ZVAL(v) v
# define Z_LVAL_PP(v) Z_LVAL_P(v)
# define Z_DVAL_PP(v) Z_DVAL_P(v)
# define STR_VAL(k) (k)->val
# define IMLIB_DELETE_RESOURCE(v) zend_list_delete(v)
# define IMLIB_RETURN_STRING(v) RETURN_STRING(v)
# define ENFORCE_SAFE_MODE 0
# define IMLIB_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)	\
	rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, resource_type_name, resource_type)
# define IMLIB_REGISTER_RESOURCE(result, le_result) RETURN_RES(zend_register_resource(result, le_result))
# define IMLIB_RSRC_DTOR_FUNC(name) ZEND_RSRC_DTOR_FUNC(name)
#else
  typedef zval* imlib_zval;
  typedef imlib_zval imlib_resource;
  typedef char zend_string;
# define IMLIB_TO_ZVAL(v) *v
# define STR_VAL(k) (k)
# define IMLIB_DELETE_RESOURCE(v) zend_list_delete(Z_LVAL_PP(v))
# define IMLIB_RETURN_STRING(v) RETURN_STRING(v, 1)
# define IMLIB_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)	\
	rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type)
# define IMLIB_REGISTER_RESOURCE(result, le_result) ZEND_REGISTER_RESOURCE(return_value, result, le_result)
  static inline void zend_string_release(zend_string *s)
  {
    efree(s);
  }
# define IMLIB_RSRC_DTOR_FUNC(name) void name(zend_rsrc_list_entry *res TSRMLS_DC)
# define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val) \
  HashPosition _pos; \
  zend_hash_internal_pointer_reset_ex(ht, &_pos); \
  for(; _pos; zend_hash_move_forward_ex(ht, &_pos)) \
  { \
    int _retval=zend_hash_get_current_key_ex(ht, &_key, NULL, &_h, 0, &_pos); \
    if (_retval!=HASH_KEY_IS_STRING) _key = NULL; \
    zend_hash_get_current_data_ex(ht, (void**)&_val, &_pos);
# define ZEND_HASH_FOREACH_END() \
  }
# define Z_RES_P(v) v
#endif

Imlib_Image _php_imlib_get_image(imlib_resource *im_resource);
Imlib_Filter _php_imlib_get_filter(imlib_resource *fil_resource);
Imlib_Font _php_imlib_get_font(imlib_resource *font_resource);
Imlib_TTF_Encoding _php_imlib_get_font_encoding(imlib_resource *font_resource);
Imlib_Color_Range _php_imlib_get_cr(imlib_resource *cr_resource);
ImlibPolygon _php_imlib_get_poly(imlib_resource *poly_resource);
Imlib_Color_Modifier _php_imlib_get_cm(imlib_resource *cm_resource);

struct php_imlib_filter
{
	char *filename;
	void *handle;
	int (*init)();
	void (*deinit)();
	int (*exec)(Imlib_Image im, char* filter, HashTable* params);
	int (*getfiltercount)();
	void (*getfilternames)(char** filternames);
        void (*getextinfo)(char** info);
        char* (*getparams)(char* filter);
	int filters;
	char** names;
	struct php_imlib_filter *next;
};

ZEND_BEGIN_MODULE_GLOBALS(imlib)
	char *font_path;
	char **saved_path;
	char *filter_path;
	long cache_size;
	long min_cache_size;
	long max_cache_size;
        struct php_imlib_filter *filters;
ZEND_END_MODULE_GLOBALS(imlib)

#ifdef ZTS
# define IMLIBG(v) TSRMG(imlib_globals_id, zend_imlib_globals *, v)
#else
# define IMLIBG(v) (imlib_globals.v)
#endif

#else	/* HAVE_IMLIB */

#define phpext_imlib_ptr NULL

#endif	/* HAVE_IMLIB */

#endif	/* _PHP_IMLIB_H */


/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 */
ViewGit